Home > Backend Development > PHP Tutorial > PHP怎么用一条语句更新多行数据

PHP怎么用一条语句更新多行数据

WBOY
Release: 2016-06-13 12:16:44
Original
896 people have browsed it

PHP如何用一条语句更新多行数据?
id      num        ps
1        123        5
2         65         12
3         12          321
4         2            25
5         55          11
..........

上面是数据表,

现在我希望不使用循环方式,只用一条语句更新
num为65,12,55的PS值各加上10
怎么实现啊?不用循环。

------解决思路----------------------
where num in (1,2,3,4,5)
------解决思路----------------------

<br />update ‘你的表名’ set ps=ps+10 where id in (2,3,5);<br />
Copy after login

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