SQL Strategy - A site to master SQL while executing it on the Web
Home >> SQL Strategy - UPDATE statement

UPDATE statement is used to update records in a table.

1. How to use UPDATE statement

--Syntax of UPDATE statement (1)
UPDATETable Name
SETcolumn name = value,column name = value...
WHEREterms

UWhen using the UPDATE statement, enter the Table Name of the record to be updated after UPDATE, and enter the item name = value to be updated after SET. When updating multiple items, use a comma-separated list of the item name = value to be updated.

The WHERE condition is used to specify which records are to be updated; an UPDATE statement updates all records that match the WHERE condition; if no WHERE condition is specified, all records are updated.

2. updating records using formulas

--UPDATE statement syntax (2)
UPDATEEMP
SET SAL = SAL * 1.5
WHEREEMPNO = 7369

You can also update the record using the value calculated and obtained during the SQL execution. In the above example, the salary of a person with Employee Number 7369 in the EMP table is multiplied by 1.5.

This completes the [ UPDATE record UPDATE statement ].