Handling multiple updates in Mysql
UPDATE yourtable
SET updatefield = CASE id
WHEN 1 THEN 'new value'
WHEN 2 THEN 'new value'
WHEN 3 THEN 'new value'
END
WHERE id IN (1,2,3)
UPDATE yourtable
SET updatefield1 = CASE id
WHEN 1 THEN 'new value'
WHEN 2 THEN 'new value'
WHEN 3 THEN 'new value'
END,
updatefield2 = CASE id
WHEN 1 THEN 'New 1'
WHEN 2 THEN 'New 2'
WHEN 3 THEN 'New 3'
END
WHERE id IN (1,2,3)
0 comments:
Post a Comment