Home  >  Article  >  Database  >  How to increase the original value in mysql

How to increase the original value in mysql

coldplay.xixi
coldplay.xixiOriginal
2020-09-28 10:54:414097browse

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语句]

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

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!

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