UPDATE with a filter in SQL
UPDATE rewrites columns in the rows WHERE matches — all of them if you forget.
UPDATE orders
SET
status = 'shipped',
shipped_at = CURRENT_TIMESTAMP,
attempts = attempts + 1
WHERE status = 'paid'
AND placed_at < '2026-07-01';
How it works
SETtakes one assignment per column, comma separated.- The
WHEREclause is what keeps the change scoped. - An expression on the right can read the column's old value.
Keywords and builtins used here
ANDCURRENT_TIMESTAMPSETUPDATEWHERE
The run, in numbers
- Lines
- 7
- Characters to type
- 145
- Tokens
- 25
- Three-star pace
- 80 tpm
At the three-star pace of 80 tokens a minute, this run takes about 19 seconds.
Step 6 of 8 in Tables & rows, step 19 of 23 in Language basics.