The LEFT OUTER JOIN (commonly written as LEFT JOIN) returns all rows from the left table (Table A), regardless of whether a matching record exists in the right table (Table B). If a match exists in Table B, its column values are returned; if no match exists, the database supplies NULL for all columns of Table B.
SELECT a.column1, b.column2
FROM table_a a
LEFT JOIN table_b b ON a.key = b.key;
-- Left Join guarantees EVERY student appears in the report
SELECT
s.student_id,
s.first_name,
COALESCE(d.dept_name, 'Unassigned') AS department,
s.gpa
FROM students s
LEFT JOIN departments d ON s.dept_id = d.dept_id;
| student_id | first_name | department | gpa |
|---|---|---|---|
| 1 | Aman | Engineering | 3.85 |
| 2 | Pooja | Business | 3.92 |
| 3 | Rohan | Engineering | 3.75 |
| 4 | Vikram | Unassigned (NULL) | 3.42 |
A common interview question: "Find all students who have not yet been assigned to any department":
SELECT s.student_id, s.first_name
FROM students s
LEFT JOIN departments d ON s.dept_id = d.dept_id
WHERE d.dept_id IS NULL; -- Filters only rows with no parent match!
Next, let us explore the mirror opposite: SQL RIGHT OUTER JOIN!
There is no difference! In standard SQL, the keyword 'OUTER' is optional; 'LEFT JOIN' and 'LEFT OUTER JOIN' are 100% synonymous.
Perform a LEFT JOIN and add a WHERE condition checking for NULL in the right table's primary key: WHERE right_table.id IS NULL.
The database automatically populates NULL across all columns of the right table for that row.
Proceed to the next class in sequence to build production mastery of relational database architecture.
Continue to Class 36: RIGHT JOIN → Previous: ← INNER JOIN | Full Syllabus
Understanding when to drop unmatched records vs keep them.
Using LEFT JOIN ... WHERE right_table.id IS NULL to find orphans.
Mirror counterpart to the left outer join.
Combining left and right outer join results.