SQL UPDATE
UPDATE changes values in rows that already exist. SET says what to change and WHERE says which rows. Without WHERE, every row changes.
Updated December 1, 2026
Syntax
UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;
Change rows that match
Raise every tea’s price by 25 cents. The new value can use the old one.
UPDATE drinks
SET price = price + 0.25
WHERE category = 'tea';
Check the result:
SELECT name, price
FROM drinks
WHERE category = 'tea';
| name | price |
|---|---|
| Matcha Latte | 5.5 |
| Chai Latte | 5 |
| Peppermint Tea | 3.5 |
Update several columns
Mark a product as restocked and adjust its price in one statement.
UPDATE products
SET stock = 50, price = 32.00
WHERE name = 'Desk Lamp';
Check the result:
SELECT name, price, stock
FROM products
WHERE category = 'office';
| name | price | stock |
|---|---|---|
| Laptop Stand | 45 | 60 |
| Desk Lamp | 32 | 50 |
| Office Chair | 199 | 8 |
Common mistakes
- Forgetting
WHERE, which updates every row in the table. Run the sameWHEREas aSELECTfirst to see what will change. - Using
=to compare NULL in theWHEREclause, so nothing updates. UseIS NULL. - Updating a column that other tables refer to (like an id) without updating those tables too.
Practice UPDATE interactively
Write real queries in your browser and get instant feedback in the lesson “UPDATE and DELETE” (Unit 9). New learners can start free from the first lesson.
Frequently asked questions
Can I undo an UPDATE?
Only inside a transaction you haven’t committed (BEGIN … ROLLBACK), or from a backup. That’s why checking with SELECT first matters.
Can I update using another table?
Yes. PostgreSQL and SQLite use UPDATE ... FROM, MySQL uses UPDATE ... JOIN. A subquery in SET or WHERE works everywhere.