我可以合并两个这样的查询
first: UPDATE table SET col1=1 WHERE id='x';
second: UPDATE table SET col1=0 WHERE id='y';
我可以加入这些查询吗?
答案 0 :(得分:4)
UPDATE table
SET col1 = CASE id WHEN 'x' THEN 1 ELSE 0 END
WHERE id IN ('x','y')
答案 1 :(得分:0)
使用此sql查询:
UPDATE table
SET col1 =
CASE id
WHEN 'x' THEN 1
WHEN 'y' THEN 0
END
WHERE id IN ('x','y');
答案 2 :(得分:0)
UPDATE table
SET col1 = (id = 'x')
WHERE id IN ('x','y');