Skip to content

SQL Update

UPDATE changes values in rows that already exist. SET says which columns get which new values, and WHERE says which rows to change.

UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;

The examples use the Invoices and Crew tables from the example database.

Invoice 1003 from Ashby Camera Hire has just been paid. To record the date, pick out the row by its ID:

UPDATE Invoices
SET PaidDate = '2025-04-08'
WHERE InvoiceID = 1003;
InvoiceID Supplier PaidDate
1003 Ashby Camera Hire 2025-04-08

An ID is the surest way to pick out one row, because no other row shares it.

The WHERE clause decides how many rows change. A new value can also be worked out from the old one. To raise the day rate of everyone in the accounts department by 25:

UPDATE Crew
SET DayRate = DayRate + 25
WHERE Department = 'Accounts';

Three rows change:

Name Department DayRate
Tom Hale Accounts 475
Priya Nair Accounts 325
Lucy Brennan Accounts 445