Home > Database > Mysql Tutorial > How to increase the original value in mysql

How to increase the original value in mysql

coldplay.xixi
Release: 2020-09-28 10:54:41
Original
4157 people have browsed it

Mysql method to increase the original value: use the update function, the format is [update table name set field name = field name 1 [where statement]].

How to increase the original value in mysql

Mysql original value increase method:

Format:

update 表名称 set 字段名称 = 字段名称 + 1  [ where语句]
Copy after login

For example, in the database There is a student table. If you want to add 1 to the score of the student with ID 1,

update student set score=score+1 where id = 1
Copy after login

If you don't add where, the system will not know which record you want to update, which will cause all the records in the table to be updated. The score is increased by 1, unless of course that's your intention.

More related free learning recommendations: mysql tutorial(video)

The above is the detailed content of How to increase the original value in mysql. For more information, please follow other related articles on the PHP Chinese website!

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