Skip to main content
SQL โ€ข LESSON 18

SQL LEFT JOIN

How can we keep all records from the left table even if no match exists in the right?

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

How can we keep all records from the left table even if no match exists in the right?

๐Ÿ’ก WHAT IS IT?

LEFT JOIN returns all records from the left table and matched values from the right table (or NULL).

๐ŸŽฏ WHAT IS IT USED FOR?

Finding customers without orders, employees without assigned departments, incomplete profiles.

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

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for SQL LEFT JOIN.

  • โœ“ LEFT JOIN
  • โœ“ NULL preservation
  • โœ“ ON condition
  • โœ“ Outer joins