[英]Update SQL multiple row value in single query with multiple column combination
enter image description here在此处输入图像描述
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我有包含这些数据的表,在执行一些操作后我想根据两列值代码和 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
I can do like this with foreach But I want to update using single query How can I achieve this?我可以用 foreach 这样做但是我想使用单个查询进行更新我怎样才能做到这一点?
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.