MS Access多联接查询 [英] MS Access Multi-Join Query

查看:96
本文介绍了MS Access多联接查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以找到此MS Access查询的问题吗?当我尝试执行它时,我在第二次左连接之前收到关于缺少运算符的错误

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

推荐答案

在Access中,您只能连接两个表.如果需要联接更多的表,则需要使用括号将第一个联接分组在一起,就好像它是一个新的派生表一样.然后,您可以将另一个表加入该组:

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)

这篇关于MS Access多联接查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆