Home  >  Article  >  Backend Development  >  续问:求教mysql批量更新有关问题

续问:求教mysql批量更新有关问题

WBOY
WBOYOriginal
2016-06-13 10:15:09995browse

续问:求教mysql批量更新问题
UPDATE table
SET s = CASE id
WHEN 1 THEN '1'
WHEN 3 THEN '2'
END
WHERE id IN (1,3)
更新一个字段这样写,要是同时更新两个或者更多字段怎么写

------解决方案--------------------
一样的啊……

update table set field_a='', field_b='',……

你的代码里''部分,被CASE WHEN语法代替了

如果别的字段还是依赖某个字段的,同样的结构代替

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn