我正在尝试添加联接,以允许查询在每个记录中为tbl_ICA.[Abbreviation]
和tbl_AssyMoves.[To ICA]
显示对应的tbl_AssyMoves.[From ICA]
。
(表的相关性如here所示)
我可以得到一个Join来正常工作,但是当我添加第二个Join时
查询表达式't1。[ICA#] = t。[From ICA] INNER JOIN t1 as t2 ON t2。[ICA#] = t。[To ICA]
的语法错误(缺少运算符)
似乎没有将第二个JOIN识别为另一个函数。在选择.[Abbreviation]
的两个不同实例时,我需要别名。
查询:
SELECT t.[Assy ID], t1.[Abbreviation], t.[From ICA], t2.[Abbreviation], t.[To ICA], t.[To Loc], t.[Date], t.Comments
FROM tbl_AssyMoves As t
INNER JOIN tbl_ICAs As t1
ON t1.[ICA #]=t.[From ICA]
INNER JOIN t1 As t2
ON t2.[ICA #]=t.[To ICA]
WHERE ((t.Date Between [Forms]![Form1]![StartDate] And [Forms]![Form1]![EndDate])
**note, additional WHERE criteria omitted for brevity**
答案 0 :(得分:1)
在进行连接时(除其他事项外),访问语法与其他dbms不同。
需要括号:
SELECT t.[Assy ID], t1.[Abbreviation], t.[From ICA], t2.[Abbreviation], t.[To ICA], t.[To Loc], t.[Date], t.Comments
FROM (tbl_AssyMoves As t INNER JOIN tbl_ICAs As t1 ON t1.[ICA #]=t.[From ICA])
INNER JOIN t1 As t2 ON t2.[ICA #]=t.[To ICA]
WHERE ((t.Date Between [Forms]![Form1]![StartDate] And [Forms]![Form1]![EndDate])