How to modify specific data in MySQL using the update command?
In MySQL, the UPDATE statement is used to modify specified data.
Here is the syntax:
UPDATE 表名 SET 列名1=新值1, 列名2=新值2, ... WHERE 条件;
The table name is the name of the table to be modified;
The column name is the name of the column to be modified;
The new value is the value to be set;
The WHERE clause is optional and used to specify the data rows to be updated.
For example, let’s say there is a table called “students” that has columns for id, name, and age. To change the name of the student with id 1 to “John” and their age to 20, you can use the following statement:
UPDATE students SET name='John', age=20 WHERE id=1;
After executing this statement, the name and age of the student with ID 1 will be updated to “John” and 20.