Lesson 14 / 37 · Joins
INNER JOIN keeps only rows that find a partner
Dennis has no department and Margaret points at a department that does not exist. An INNER JOIN drops both without a warning. The join step counts them for you: "left rows dropped: no match".
The query
SELECT e.name, d.name AS department
FROM employees e
JOIN departments d ON d.id = e.dept_id
Try adding AND d.name <> 'Sales' to the ON condition: Grace and Ken drop out too, because in an inner join ON filters the way WHERE does.
Next: LEFT JOIN keeps every left row and fills the gaps with NULL · All lessons