Understanding LEFT JOIN in SQL: A Simple Guide

Estimated study time: 7 minutes. Keep every row from the left table, matched or not.

A LEFT JOIN (also called LEFT OUTER JOIN) returns every row from the left table, along with matching rows from the right table. Where there's no match, the right table's columns come back as NULL.

Basic Syntax

SELECT columns
FROM TableA
LEFT JOIN TableB ON TableA.key = TableB.key;

A Practical Example

SELECT Employees.EmpName, Departments.DeptName
FROM Employees
LEFT JOIN Departments ON Employees.DeptID = Departments.DeptID;

Every employee shows up here — even one with no assigned department, whose DeptName simply appears as NULL.

LEFT JOIN vs INNER JOIN

An INNER JOIN would silently drop that unmatched employee. A LEFT JOIN keeps them, which makes it the right tool whenever "show me everything, plus whatever matches" is the goal.

Finding Rows With No Match

A common pattern pairs LEFT JOIN with a NULL check to find rows in the left table that have no counterpart at all:

SELECT Employees.EmpName
FROM Employees
LEFT JOIN Departments ON Employees.DeptID = Departments.DeptID
WHERE Departments.DeptID IS NULL;
💡 Tip: Table order matters in a LEFT JOIN — swapping TableA and TableB changes which side keeps all its rows.

Ready to go beyond the basics?

Get hands-on training, live mentorship, and placement support with Uncodemy's Data Analytics Course.

Explore Data Analytics Course →