An employee-manager Self JOIN connects an employee row to another row in the same Employees table representing the employee's manager.
Organizational hierarchy reporting is a common requirement in HR and workforce analytics.
Display employee names and their manager names.
SELECT
e.EmployeeID,
e.EmployeeName,
m.EmployeeName AS ManagerName
FROM Employees e
LEFT JOIN Employees m
ON e.ManagerID = m.EmployeeID;
Used in HR reports, organizational charts, approval workflows, and management dashboards.
- Employee and manager can exist in the same table.
- ManagerID points to another EmployeeID.
- The table needs two aliases.
- LEFT JOIN keeps top-level employees.
- This is a common hierarchical data pattern.
How do you find an employee's manager using SQL?
Use a Self JOIN between the employee's ManagerID and another row's EmployeeID.
Why use LEFT JOIN here?
It keeps employees whose ManagerID is NULL, such as top-level managers.