0PricingLogin
SQL Interview Prep · Lesson

LEFT JOIN and Preserving Unmatched Rows

What LEFT JOIN keeps and how NULLs appear for non-matching rows.

The Interview Setup

An interviewer says: "List every customer and their orders, including customers who have never ordered." An INNER JOIN drops the customers with no orders, so it fails this requirement. The job goes to LEFT JOIN.

A LEFT JOIN keeps every row from the left (first-named) table, and attaches matching rows from the right table when they exist. This lesson builds the precise mental model interviewers expect.

What LEFT JOIN Guarantees

The core promise: every row from the left table appears in the output at least once, matched or not.

  • If a left row finds matches on the right, you get one output row per match.
  • If a left row finds no match, you still get one output row, with all right-table columns set to NULL.

This is why interviewers call it an outer join: rows that fall outside the match set are preserved instead of discarded.

All lessons in this course

  1. LEFT JOIN and Preserving Unmatched Rows
  2. RIGHT and FULL OUTER JOIN Semantics
  3. Finding Rows With No Match (Anti-Join)
  4. The WHERE-on-Outer-Join Trap
← Back to SQL Interview Prep