Skip to main content
SQL โ€ข LESSON 79

LEFT JOIN

How can we keep employees even when they have no department match?

Intermediateโฑ 3 Minutesโญ 920 XP
๐Ÿค” THE QUESTION

How can we keep employees even when they have no department match?

๐Ÿ’ก WHAT IS IT?

A LEFT JOIN preserves all rows from the left table, filling non-matching right-table fields with NULL.

๐ŸŽฏ WHAT IS IT USED FOR?

Preserving all employees, unassigned staff auditing, optional relationship joins.

๐Ÿ’ป EXAMPLE
SELECT e.name, d.department_name
FROM employees e
LEFT JOIN departments d
ON e.department_id = d.department_id;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for LEFT JOIN.

  • โœ“ LEFT JOIN
  • โœ“ Outer join
  • โœ“ Preserving left rows
  • โœ“ NULL handling