访问 - 第三个左连接,多个条件不起作用

时间:2018-05-15 14:48:28

标签: sql ms-access join

我正在尝试使用LEFT JOIN合并来自多个表(至少6个)的数据。当我不再向查询添加第三个LEFT JOIN时,我收到错误'JOIN EXPRESSION NOT SUPPORTED'。

SELECT *
FROM
(
(Flat_File ff
left join Cost_Drivers cd on cd.Cost_Driver_Reported_Name = ff.Cost_Driver)
left join BM_IAA bmiaa on bmiaa.Section_Name = cd.Cost_Driver_Billing_Model_Section_Name)
left join BM_Allocations bma 
on
(bma.Fiscal_Year = ff.Fiscal_Year) and (bma.Section_Name = cd.Cost_Driver_Billing_Model_Section_Name)

这样做会给我“不支持连接表达式”错误。但是,如果我删除最后一个Left Join中的一个条件,它就可以了。我有语法问题吗?

1 个答案:

答案 0 :(得分:1)

在MS Access中,如果您有多个关节,则必须用括号括起所有连接。

您的查询应该是

SELECT *
FROM
(((Flat_File ff
left join Cost_Drivers cd on cd.Cost_Driver_Reported_Name = ff.Cost_Driver)
left join BM_IAA bmiaa on bmiaa.Section_Name = cd.Cost_Driver_Billing_Model_Section_Name)
left join BM_Allocations bma 
   on ((bma.Fiscal_Year = ff.Fiscal_Year) and (bma.Section_Name = cd.Cost_Driver_Billing_Model_Section_Name)))