UPDATE multiple tables in MySQL using LEFT JOIN
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
MySQL lets you update rows based on joined tables, and that is often what people mean when they ask about UPDATE ... LEFT JOIN. The important distinction is whether you are updating one target table using data from a joined table, or updating multiple joined tables in the same statement. MySQL supports both, but the join shape and SET logic need to be explicit.
Updating One Table Based on a LEFT JOIN
A very common pattern is: keep every row from the left table, join optional data from the right table, and update the left table based on whether a match exists.
Here is what happens:
- every row from
customersis considered - matching paid orders are joined when present
- the
CASEexpression turns the presence or absence of a match into the new column value
The LEFT JOIN matters because customers with no matching order still stay in the update set.
Updating More Than One Table at Once
MySQL can also update columns in multiple joined tables in a single statement.
This updates both orders and shipments for the joined rows.
That power is useful, but it also increases risk. When more than one table is being modified, you should be extra careful about the join cardinality and the WHERE clause.
Why LEFT JOIN Can Surprise You
A LEFT JOIN does not magically create a row in the right table. If there is no match, right-side columns are NULL. That means a statement like this:
only affects rows where orders actually exists. The join still keeps every customer row logically, but there is nothing to update on the right side when the match is missing.
So LEFT JOIN is most useful when:
- the left table must remain in scope even with missing matches
- the
SETclause usesCASE,IFNULL, orCOALESCEstyle logic - you want to derive flags or summary columns from optional related rows
Preview the Rows First
Before running a joined update, run the same join as a SELECT.
This is the safest habit for debugging. If the preview result is wrong, the update will be wrong too.
Watch Out for Duplicate Matches
A joined update becomes dangerous when one row in the left table matches several rows on the right. You may think you are applying one simple update, but the join may produce multiple candidate matches.
If your logic expects one related row, enforce that assumption with:
- stricter join conditions
- aggregation in a subquery
- uniqueness constraints in the schema
Without that, the result can be confusing or unintuitive.
Common Pitfalls
The most common mistake is forgetting to preview the join with a SELECT before running the UPDATE.
Another mistake is assuming LEFT JOIN means missing right-side rows can still be updated. They cannot.
A third pitfall is ignoring duplicate matches in the joined table, which can make the update behave differently than expected.
Summary
- Use
UPDATE ... LEFT JOINwhen the update logic depends on optional related rows. - A
LEFT JOINkeeps all left-table rows in scope, even when the right side is missing. - MySQL can update one joined table or multiple joined tables in the same statement.
- Preview the join as a
SELECTbefore executing the update. - Be careful with duplicate matches and
NULLright-side values.

