How to Update Rows in PostgreSQL

Last updated July 24, 2026 · By the SaturnSQL team

Use UPDATE ... SET ... WHERE, with FROM to join another table. RETURNING shows exactly which rows changed, which doubles as a safety check.

RETURNING makes UPDATE report back the rows it changed, so you can confirm the effect in the same round trip instead of following up with a SELECT. It accepts any expression and pairs well with a transaction you can roll back if the output looks wrong.

UPDATE orders
SET status = 'shipped'
WHERE id = 42
RETURNING id, status;

Update from another table

The FROM clause joins another table into the update. The critical detail is that the join condition lives in WHERE, and leaving it out cross-joins the tables so every row gets a value from an arbitrary match. If one order matches several customers, Postgres picks one non-deterministically rather than raising an error.

UPDATE orders o
SET region = c.region
FROM customers c
WHERE c.id = o.customer_id;

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related PostgreSQL guides