MySQL Joins, Subqueries, and CTEs Cheatsheet/Left join to keep unmatched parent rows

Return all rows from the left table and matching rows from the right table.

Section: joins

Left join to keep unmatched parent rows

sql
sql
SELECT u.id, u.email, o.id AS order_id
FROM users u
LEFT JOIN orders o ON o.user_id = u.id;
Explanation

Rows from `users` remain even when there is no matching row in `orders`.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing joins
Inner join two tables
Return rows where both tables match.
OpenIn sheetsqlsame section
Join and aggregate child rows
Count child rows per parent.
OpenIn sheetsqlsame section
Self join a table
Join a table to itself using aliases.
OpenIn sheetsqlsame section
Join to a derived table
Compute an aggregate once and join it back.
OpenIn sheetsql1 tag match
Filter with a subquery
Return users who have at least one paid order.
Use EXISTS for correlated filtering
Return users who have orders.