How to Update Rows in MySQL
Last updated July 24, 2026 · By the SaturnSQL team
Use UPDATE ... SET ... WHERE. Join another table directly in the UPDATE to copy values across tables. Safe-updates mode blocks UPDATEs without a key in the WHERE clause.
Run the WHERE clause as a SELECT first. UPDATE reports how many rows changed, but by then it is done, and MySQL has no RETURNING clause to show you what it touched. Rows where the new value equals the old one count as matched but not changed, which explains a smaller number than you expected.
UPDATE orders SET status = 'shipped' WHERE id = 42;Update with a join
MySQL allows the join directly in the UPDATE, which is the concise way to copy values between tables. Every matching row is updated, so an accidentally broad join condition rewrites far more than intended. Safe-updates mode, on by default in MySQL Workbench and some clients, rejects an UPDATE whose WHERE does not use a key; SET SQL_SAFE_UPDATES = 0 turns it off for the session.
UPDATE orders o
JOIN customers c ON c.id = o.customer_id
SET o.region = c.region;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