Module lessons (2/4)
Keep Everything on the Left: LEFT JOIN
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 JOINandWHERE destra.id IS NULL(anti-join). - Avoid the classic bug of putting conditions on the right table inside
WHEREinstead of theONclause.
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
- 11. Mental Model: Filter in
ONvs Filter inWHERE - 22. Progressive & Annotated Examples
- 33. Interactive Laboratory: LEFT JOIN vs ANTI JOIN
- 44. Diagnostic Verification (Quiz)
- 55. Progressive Practical Laboratory
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.