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?

Intermediate3 Minutes310 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