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';
Result on the SQL Café sample data (3 rows)
nameprice
Matcha Latte5.5
Chai Latte5
Peppermint Tea3.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';
Result on the Desk & Co. (online store) sample data (3 rows)
namepricestock
Laptop Stand4560
Desk Lamp3250
Office Chair1998

Common mistakes

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.

Related SQL tutorials