UPDATE Statement Examples

SQL statement

Description

 

UPDATE Employees
SET [Reports To] = 5
WHERE [Reports To] = 2;

Changes values in the Reports To field to 5 for all employee records that currently have Reports To values of 2.

UPDATE Products
SET [Unit Price] = [Unit Price] * 1.1
WHERE [Supplier ID] = 8
AND Discontinued = No;

Increases the Unit Price for all nondiscontinued products from supplier 8 by 10 percent.

UPDATE Products, Suppliers, Suppliers
INNER JOIN Products
ON Suppliers.[Supplier ID] = Products.[Supplier ID]
SET [Unit Price] = [Unit Price] * .95
WHERE [Company Name] = 'Tokyo Traders' AND Discontinued = No;

Reduces the Unit Price for all nondiscontinued products supplied by Tokyo Traders by 5 percent.  The Products and Suppliers tables have a one-to-one relationship.