I am trying to lookup a manager’s name from only the Employee_ID, Manager_ID, Employee Name within the same table.
Here is the data I have to work with.
SELECT EmployeeID, EmployeeName, Employee_Job_Title, Manager_ID, Managers_Position
I’d like the results to look like:
| EmployeeID | EmployeeName | Employee_Job_Title | Manager_ID | ManagerName | Managers_Position |
|---|---|---|---|---|---|
| 1234 | Jason | Teller | 2345 | Mason | Teller Manager |
I know this can happen based on some type of join on the EmployeeIDs but I’m not sure how to make it happen.
Thanks for the help!!
>Solution :
select
e.EmployeeID,
e.EmployeeName,
e.Employee_Job_Title,
e.Manager_ID,
m.EmployeeName as ManagerName,
e.Managers_Position
from employee_table e
left join employee_table m on e.Manager_ID = m.Employee_ID