Skip to main content
Module 3 · Lesson 2 of 410/57 in the course~14 min
Module lessons (2/4)

Keep Everything on the Left: LEFT JOIN

Lesson preview5 hands-on exercises readySQL Course · Module 3 — JOIN and GROUP BY

Preserve unmatched rows from the left table instead of dropping them.

What you'll learn in this lesson

  • Keep all table rows on the left even without matching on the right using LEFT JOIN.
  • Discover "orphan" or inactive records by combining LEFT JOIN and WHERE destra.id IS NULL (anti-join).
  • Avoid the classic bug of putting conditions on the right table inside WHERE instead of the ON clause.

Overview

If INNER JOIN discards unlinked records (such as Andrea Costa with no department or books never lent), LEFT JOIN ensures that every single row of the left table (FROM) survives in the result, filling the missing columns on the right with NULL.

Toggle the LEFT and ANTI buttons in the simulator to see how unmatched employees (Diana, Evan) first appear with badges NULL and then are isolated by the WHERE d.id IS NULL filter:

Sections covered in this lesson

  1. 11. Mental Model: Filter in ON vs Filter in WHERE
  2. 22. Progressive & Annotated Examples
  3. 33. Interactive Laboratory: LEFT JOIN vs ANTI JOIN
  4. 44. Diagnostic Verification (Quiz)
  5. 55. Progressive Practical Laboratory
Pro Lesson · Module 3 — JOIN and GROUP BY

Unlock "Keep Everything on the Left: LEFT JOIN" and the full SQL Course curriculum

Preserve unmatched rows from the left table instead of dropping them.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in SQL Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.