Reputation: 1253
column1 = value WHERE cond='1'
column2 = value WHERE cond='2'
In the example above. Is this the right way to code it in mysql
UPDATE table SET (column1='value' WHERE cond='1') OR (column2='value' WHERE cond='2')
Upvotes: 0
Views: 18
Reputation: 7779
UPDATE
table
SET
column1 = (CASE cond WHEN '1' THEN 'value' ELSE column1 END)
, column2 = (CASE cond WHEN '2' THEN 'value' ELSE column2 END)
WHERE
cond IN ('1', '2')
;
Upvotes: 1