DiH DiH - 9 months ago 37
SQL Question

Update only in case where its not null

I want update a column(a) from table1 with select from table2 but making update only when in table2 existing column(b) is not null. I dont want use where statement (is not null) cause it will influence all my code.

Example of my code:

update table1 set column(a) = (select column(b) from table2)

I'm trying something like this

update table1 set column(a) = not null(select column(b) from table2)


update ExpressMarketCheck set Barcode = (select barcode from ExpressMarket), Name=(select name from expressmarket), price=(select price from expressmarket)


You can use this query to achieve your constraint.

Update ExpressMarketCheck set Barcode = (select barcode from ExpressMarket where barcode IS NOT NULL)