enter image description here
我有一个包含这些数据的表,在做了一些操作后,我想根据两列值code和id将标志值从0更新为1
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
我可以用foreach这样做,但是我想用单个查询来更新,我该怎么做呢?
1条答案
按热度按时间qjp7pelc1#
这个应该可以
UPDATE table SET flat = 1 WHERE (code = 'ABC' and id = 10000) OR (code = 'DEF' and id = 10001) OR (code = 'GHI' and id = 10002)