2017-06-05 50 views
0

我有一個問題與訪問2016年別名聯接。我有一個表'項目',其中包括僱主,最終用戶,買方領域。每個字段都引用同一個表'客戶'。 我想列出項目名稱,業主和買方與此SQL:多個加入兩個表中不能在Access 2016工作

SELECT Projects.[Project Name],A.Company as employer,B.company as Purchaser 
FROM Projects INNER JOIN Clients as A ON Projects.Employer = A.ID 
INNER JOIN Clients B ON Projects.Purchaser = B.ID; 

我得到一個錯誤:

Syntax error(missing operator) in query expression Projects.Employer = A.ID INNER JOIN Clients B ON Projects.Purchaser = Clients.ID;

想不通這是怎麼回事,因爲每個專用連接工作正常,但當我把它們放在一起時,我會得到錯誤!

回答

0

訪問對於接受的SQL有點奇怪,你絕對必須在大多數情況下改變你的語法。我相信,多個內部連接,你需要添加一些括號

這應該工作:

SELECT Projects.[Project Name],A.Company as employer,B.company as Purchaser 
FROM (Projects INNER JOIN Clients as A ON Projects.Employer = A.ID) 
INNER JOIN Clients B ON Projects.Purchaser = B.ID;