SQL UPDATE Statement

The UPDATE statement modifies existing rows in a table. It is one of the core Data Manipulation Language (DML) commands.

Syntax

UPDATE table_name
SET column1 = value1,
    column2 = value2,
    ...
[WHERE condition]
[ORDER BY column]
[LIMIT number_of_rows];

Basic Example

Update the Salary of employees in the Employees table.

UPDATE Employees
SET Salary = Salary * 1.10
WHERE Department = 'Sales';

Updating Multiple Columns

UPDATE Products
SET Price = Price * 0.9,
    Stock = Stock + 100
WHERE Category = 'Electronics';

Using Joins in UPDATE

Update rows based on a join with another table.

UPDATE Orders o
JOIN Customers c ON o.CustomerID = c.ID
SET o.Status = 'Processed'
WHERE c.Region = 'North America';

Common Pitfalls

Related Topics