SELECT E1.Name AS Empl, E2.Name AS HeadOfDepartment
FROM EMPLOYEE AS E1 INNER JOIN DEPARTMENT AS Dep
ON E1.DepartmentNr=Dep.DepartmentNr
INNER JOIN EMPLOYEE AS E2
ON Dep.Head=E2.EmployeeNr
ORDER BY Dep.Name;
我不知道错误在哪里。
答案 0 :(得分:0)
尝试以下查询。
SELECT E1.Name AS Empl, E2.Name AS HeadOfDepartment
FROM EMPLOYEE AS E1 INNER JOIN DEPARTMENT AS Dep
ON E1.DepartmentNr=Dep.DepartmentNr
INNER JOIN E1 ON Dep.Head = E1.EmployeeNr
ORDER BY Dep.Name;
答案 1 :(得分:0)
Access数据库有一种奇怪的语法。您的SQL语句应该适用于大多数服务器类型数据库。无论如何,请尝试下面的代码,看看它是否适用于您的访问。
SELECT E1.Name AS Empl,
E2.Name AS HeadOfDepartment
FROM EMPLOYEE AS E1
INNER JOIN (DEPARTMENT AS Dep
INNER JOIN EMPLOYEE AS E2
ON Dep.Head=E2.EmployeeNr)
ON E1.DepartmentNr=Dep.DepartmentNr
ORDER BY Dep.Name;