I have table with these datas, after do some operations I want to update flag value from 0 to 1 based on the two columns value code and id
update table set flag = 1 where code = 'ABC' and id = 10000
update table set flag = 1 where code = 'DEF' and id = 10001
update table set flag = 1 where code = 'GHI' and id = 10002
update table set flag = 1 where code = 'ABC' and id = 10001
I can do like this with foreach But I want to update using single query How can I achieve this?
CodePudding user response:
this should work
UPDATE table SET flat = 1 WHERE (code = 'ABC' and id = 10000) OR (code = 'DEF' and id = 10001) OR (code = 'GHI' and id = 10002)