lundi 28 janvier 2019

SQL If condition is true Update table

i am trying to write a one line sql statement that can check for a certain condition and if the condition is met I need to update a table with a new value. below is what I want to do, I just cant find out how to accomplish this. any help would be greatly appreciated.

if (select * from table
    where field1 = '0000000001' and field2 = 'XXX')
update table set field1 = '9876543210'
where field2 = 'XXX';

I am getting the following error:

An expression of non-Boolean type specified in a context where a condition is expected, near 'update'

Aucun commentaire:

Enregistrer un commentaire