Link to home
Start Free TrialLog in
Avatar of mohantyd
mohantydFlag for India

asked on

SQL Query Help

I have atable with 3 columns EmpID, EmpName and ManagerID. Every Employee has amanager and manager also an employee. If i Give EmpID in query it should return me Epmloyee name and manager name. What will be the query ?
Avatar of Ryan McCauley
Ryan McCauley
Flag of United States of America image

You don't specify your table name, so I'll assume is "Employees". I think you're looking for:

SELECT e1.EmpName, e2.EmpName as ManagerName
  FROM Employees e1
  JOIN Employees e2
    ON e1.ManagerID = e2.EmpID
 WHERE e1.EmpID = "Your Employee ID Here"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mayank_joshi
mayank_joshi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial