SQL UPDATE statement
The Update statement is used to modify data in the table. The syntax is as follows:
UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
"Person" Table:
LastName FirstName Address City Gates Bill Xuanwumen 10 Beijing Wilson Champs-Elysees
Update a column in a row
UPDATE Person SET FirstName = "Fred" WHERE LastName = "Wilson"
Result:
LastName FirstName Address City Gates Bill Xuanwumen 10 Beijing Wilson Fred Champs-Elysees
Note: This example adds firstname to the person whose lastname is "Wilson".
Update several columns in a row
UPDATE Person SET Address = "Zhongshan 23", City = "Nanjing" WHERE LastName = "Wilson"
Result:
LastName FirstName Address City Gates Bill Xuanwumen 10 Beijing Wilson Fred Zhongshan 23 Nanjing
Note: This example will modify the address (address ), and add the city name (city).
The above is the detailed content of How to use UPDATE statement in SQL. For more information, please follow other related articles on the PHP Chinese website!