How to modify table content in MySQL?
To modify table contents, you can use the UPDATE statement in MySQL. Here is an example:
UPDATE 表名 SET 列名1 = 值1, 列名2 = 值2 WHERE 条件;
In this, table name refers to the name of the table you want to modify, column name 1 and column name 2 refer to the names of the columns you want to update, value 1 and value 2 are the new values you want to set, and condition is a logical expression used to specify the rows to update.
Here is a specific example:
Assume you have a table named ‘student’ with three columns: id, name, and age. Now, if you want to change the name of the student with id 1 to “John” and set their age to 20, you can use the following statement to complete this operation:
UPDATE student SET name = 'John', age = 20 WHERE id = 1;
This will change the name of the student with ID 1 to “John” and the age to 20.
Before executing the UPDATE statement, make sure you are connected to the correct database and have sufficient permissions to modify table contents.