Home > Backend Development > PHP Tutorial > mysql 如何累加?

mysql 如何累加?

WBOY
Release: 2016-06-23 14:17:33
Original
1056 people have browsed it

MySQL

比如现在我有个值897存在MYSQL里头
新加入763 最终得到897+763

是不是一定要先访问MYSQL取897然后加上763

再写入MYSQL

我现在想要的是 有没有不用先取897直接写入763而写入的值是897+763

等于就是想少访问一次MYSQL

回复讨论(解决方案)

本帖最后由 xuzuning 于 2013-07-30 11:28:43 编辑

如果是数值
updatetbl_name set field_name=field_name+763
field_name 变为 1660

如果是串
updatetbl_name set field_name=concat(field_name, '763')
field_name 变为 897763

楼上正解

多谢~~~~~~~~~~

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