Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - MySQL: How to update the value of a field to the original value plus 1
MySQL: How to update the value of a field to the original value plus 1

Format: update table name set field name = field name + 1 [where statement]

For example, there is a student table in the database, and you want to get the student score with id 1 ( score) plus 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, and Causes all scores in the table to be increased by 1, unless of course that's your intention.