ID Name ManagerID
1 Balaji NULL
2 Ashish 1
3 Divya 1
4 Nidhish 2
Write a query to display ManagerName (ManagerID is foreign key to ID)/
SELECT e.ID, e.Name, mgr.Name AS ManagerName
FROM Employee AS e LEFT OUTER JOIN
Employee AS mgr ON e.ManagerID = mgr.ID
Result:
1 Balaji NULL
2 Ashish Balaji
3 Divya Balaji
4 Nidhish Ashish
No comments:
Post a Comment