Skip to the workspace
Pebellslearn by building
Data Manipulation Language (DML)  ›  Lesson

UPDATE — Changing Rows

UPDATE 15 minUPDATE changes column values in the rows chosen by WHERE, and without a WHERE clause it changes every row in the table.

sql / UPDATE — Changing Rows

Explore each scene at your own pace.

01 · The rule

The rule

UPDATE — Changing Rows

UPDATE changes column values in the rows chosen by WHERE, and without a WHERE clause it changes every row in the table.

Identify the rows selected by a predicate before computing their new values.

Stationery prices are going up by 10%. One short statement can change every notebook and pen in the catalogue at once. The same statement, missing one line, changes the price of every product the shop sells. UPDATE is powerful precisely because it works on many rows at a time.

The rule

SET says what changes; WHERE says which rows — never forget WHERE.

UPDATE products
SET price = price * 1.10
WHERE category = 'stationery';
  • UPDATE products — which table.
  • SET price = price * 1.10 — the new value. The right-hand side can use the row's current values, so each product's own price is raised: a 60.00 notebook becomes 66.00 and a 25.00 pen becomes 27.50.
  • WHERE category = 'stationery' — which rows. Only these change.

To change several columns, separate the assignments with commas:

UPDATE orders
SET status = 'shipped', order_date = '2026-03-06'
WHERE order_id = 106;

Without WHERE, every row in the table is updated. There is no warning and no "are you sure?". Some tools add a safety switch (MySQL Workbench's safe-update mode, for example), but you cannot count on one being there.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.