SQL JOINs Explained: INNER vs LEFT with Practical Examples
Understand INNER JOIN and LEFT JOIN behavior with practical SQL examples you can reuse in real queries.
Last updated: May 4, 2026
INNER JOIN
Returns only rows that match on both sides of the join condition.
SELECT o.id, u.email FROM orders o INNER JOIN users u ON u.id = o.user_id;
LEFT JOIN
Returns all rows from the left table, even if there is no matching row on the right. Missing matches become NULL.
SELECT u.id, u.email, o.total_amount FROM users u LEFT JOIN orders o ON o.user_id = u.id;
Common mistakes
- Filtering right-table columns in WHERE after LEFT JOIN, which turns it into an INNER JOIN effect.
- Joining on non-unique fields, causing duplicate result rows.
- Using SELECT * in complex joins, making debugging harder and payloads larger.
Recommended pattern
Start with the smallest correct join, validate row count, then add filters and selected fields incrementally. Format the query after each change to keep logic readable during reviews.