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_nameSET column1 = value1, column2 = value2WHERE condition;The examples use the Invoices and Crew tables from the example database.
Changing one row
Section titled “Changing one row”Invoice 1003 from Ashby Camera Hire has just been paid. To record the date, pick out the row by its ID:
UPDATE InvoicesSET 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.
Changing several rows
Section titled “Changing several rows”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 CrewSET DayRate = DayRate + 25WHERE Department = 'Accounts';Three rows change:
| Name | Department | DayRate |
|---|---|---|
| Tom Hale | Accounts | 475 |
| Priya Nair | Accounts | 325 |
| Lucy Brennan | Accounts | 445 |