Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Can anyone find what is wrong with this MS Access Query? When I try to execute it i receive an error about a missing Operator before the 2nd Left Join

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
932 views
Welcome To Ask or Share your Answers For Others

1 Answer

In Access you can only join two tables. If you need to join more tables, you need to group the first join together using parentheses, as if it was a new derived table. Then you can join another table to that group:

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

(I'm using awkward indentation to try to make the groups more clear)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...