SQL查询从表中查找EmployeeName,Manager Name

时间:2014-07-26 08:34:43

标签: sql

我有两张表如下

EmployeeTable

enter image description here

Employe_Manger

enter image description here

请注意,E1E2的经理,E3E4E5的经理。

现在找到一个查询,找出经理姓名和员工姓名。

即。结果应该是

enter image description here

1 个答案:

答案 0 :(得分:3)

SELECT one.EmployeeName AS "Employee", two.EmployeeName AS "Manager"
FROM Employee AS one
INNER JOIN Employee_Manager AS temp ON one.EmployeeId = temp.EmployeeId
INNER JOIN Employee AS two ON temp.ManagerId = two.EmployeeId

这是你想要达到的目标吗?