Lesson 18 of 30
LEFT JOIN
Today at the studio
The Marketing department has an office on the third floor and, so far, no one in it. When you list departments with their staff, Marketing vanishes. "A department that disappears?" says Rin. "Even Kou never managed that."
The idea
LEFT JOIN keeps every row of the left table, even when nothing on the right matches. For those rows, the columns of the right table are NULL.
Use it when the left table is the list you care about, like all departments or all shows, and the other table is optional extra information.
Example
SELECT departments.floor, staff.name FROM staff LEFT JOIN departments ON staff.department_id = departments.id
Your turn
0 of 4 questions
Question 1 of 4
Show every department with the names of its staff. Departments with nobody must still appear.