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

WBOY
Release: 2016-06-13 10:15:09
Original
987 people have browsed it

续问:求教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语法代替了

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!