In mysql, you can use the Update statement to modify the value of a column. The Update statement is used to modify and update the data of one or more tables. With the WHERE condition, you can modify the data value of the specified column. The syntax is "UPDATE table name SET column name = new value WHERE column name = some value".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
In MySQL, you can use the UPDATE statement to modify and update the data of one or more tables.
Basic syntax of the UPDATE statement
Use the UPDATE statement to modify a single table. The syntax format is:
UPDATE <表名> SET 字段 1=值 1 [,字段 2=值 2… ] [WHERE 子句 ] [ORDER BY 子句] [LIMIT 子句]
The syntax description is as follows:
722e3d59fd24604761db25f00f9b264f: used to specify the name of the table to be updated.
SET clause: used to specify the column name and its column value to be modified in the table. Among them, each specified column value can be an expression or the default value corresponding to the column. If a default value is specified, the column value can be represented by the keyword DEFAULT.
WHERE clause: Optional. Used to limit the rows in the table to be modified. If not specified, all rows in the table will be modified.
ORDER BY clause: Optional. Used to limit the order in which rows in a table are modified.
LIMIT clause: Optional. Used to limit the number of rows that are modified.
Note: When modifying multiple column values in a row of data, each value in the SET clause can be separated by commas.
Mysql syntax for modifying the value of a column:
UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
Update a column in a certain row
We add for people whose lastname is "Wilson" firstname:
UPDATE Person SET FirstName = 'beijing' WHERE LastName = 'shanghai'
Update several columns in a row
We will modify the address (address) and add the city name (city):
UPDATE Person SET Address = 'jinqiaolu', City = 'shanghai' WHERE LastName = 'beijing'
Recommended learning: mysql video tutorial
The above is the detailed content of How to modify the value of a column in mysql. For more information, please follow other related articles on the PHP Chinese website!