Why is the CEO missing from the result?
SELECT e.name, m.name AS boss FROM emp e JOIN emp m ON e.manager_id = m.id; -- the CEO (manager_id NULL) is missing
- A table can never be joined to itself
m.nameoverwritese.namehere- Aliases hide rows from the output
- An inner join drops the NULL manager
NULL = m.id is never true, so the inner self-join discards the CEO; a LEFT JOIN keeps it with a NULL boss.