Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道这不起作用:
UPDATE `states` SET `country_id` = '83', `position` = (1,2,3) WHERE `states`.`id` IN (381, 378, 380);
有没有办法根据
id = 381; position = 1 id = 378; position = 2 id = 380; position = 3
谢谢。
最简单的是使用三个单独的查询。
单个查询是可能的,但更复杂:
UPDATE states SET country_id = '83', position = CASE id WHEN 381 THEN 1 WHEN 378 THEN 2 WHEN 370 THEN 3 END WHERE id IN (381, 378, 380)