2013-09-25 189 views
1

任何人都可以找到這個MS Access查詢有什麼問題嗎?當我嘗試執行它時,我收到第二個左連接之前丟失的運算符的錯誤MS Access多連接查詢

SELECT * FROM (
SELECT GetitUsageTemp.MemberID, 
    GetitUsageTemp.IDNumber, 

    GetitUsageTemp.Title, 
    GetitUsageTemp.Initials, 
    GetitUsageTemp.Forenames, 
    GetitUsageTemp.Surnames, 
    GetitUsageTemp.CellNumber, 
    GetitUsageTemp.EmailAddress, 

    Nz(August.[AugustUsage],0) AS AugustUsage 

FROM GetitUsageTemp 
LEFT JOIN 
(SELECT dbo_Requests.fk_Members_ID, Count(dbo_Requests.Log_date) AS JulyUsage 
FROM dbo_Requests 
WHERE dbo_Requests.Log_date Between #07/01/2013# And #08/01/2013# 
GROUP BY dbo_Requests.fk_Members_ID 
) Requests 
ON GetitUsageTemp.MemberID = Requests.fk_Members_ID 

LEFT JOIN 

(SELECT dbo_Requests.fk_Members_ID, Count(dbo_Requests.Log_date) AS AugustUsage 
FROM dbo_Requests 
WHERE dbo_Requests.Log_date Between #08/01/2013# And #09/01/2013# 
GROUP BY dbo_Requests.fk_Members_ID 
) August 
ON GetitUsageTemp.MemberID = August.fk_Members_ID 
)GETIT 
+0

爲什麼'mysql'標籤?你使用Access作爲MySQL數據庫的前端嗎? –

回答

2

在Access中,您只能連接兩個表。如果您需要連接更多表,則需要使用圓括號將第一個連接組合在一起,就像它是一個新的派生表一樣。然後你就可以加入其他表到該組:

select 
    * 
from 
    ((Table1 
     LEFT JOIN Table2 ... 
    ) 
    LEFT JOIN Table3 ... 
) 
    LEFT JOIN Table4 ... 

(我用笨拙的壓痕,力圖使組更清晰)

+0

感謝很多,你已經救了我的一天 – hlosukwakha