Lesson 16 — LEFT JOIN: keep rows without a match
LEFT JOIN: keep rows that have no match
An INNER JOIN drops rows with no partner: a customer with no orders vanishes. A LEFT JOIN keeps every row of the left table; where no match exists, the right table's columns are NULL (SQL's "no value", shown as None in Python). COALESCE(x, 0) replaces NULL with 0.
SELECT a.name, p.title
FROM authors a LEFT JOIN posts p ON p.author_id = a.id
Why it matters: "customers who never ordered" and "products never sold" are only visible with a LEFT JOIN — often the most valuable rows in a report.
Change JOIN to LEFT JOIN so Cy (no orders) also appears, with 0 orders. Expected: Ann 2, Bo 1, Cy 0.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based Databases & SQL courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for Databases & SQL books — check the publication year so the examples match current versions.
Search Amazon →