Resolve a manager relationship stored in the same table.
Section: Self joins
Employee to manager self join
sql
sql
SELECT e.employee_id,
e.name AS employee_name,
m.name AS manager_name
FROM employees e
LEFT JOIN employees m ON m.employee_id = e.manager_id;Explanation
Alias the same table twice so each role is clear.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Self joins
Find duplicate emails with self join
Compare rows in the same table using inequality to avoid mirrored duplicates.
Use self join for one-level hierarchy
Great for direct parent relationships like employee → manager.