不支持访问SQL JOIN表达式

时间:2015-11-27 13:24:41

标签: sql ms-access

我知道在这里处理不受支持的连接表达式有很多问题,我找不到一个引用我的情况。

我的查询如下:

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
INNER JOIN Groups AS T4 ON  T4.ID = " & (Me.Texte423) & "
ORDER BY Categories, T1.Questions;

正如您在线上可以看到引用T4的那样,我正在尝试匹配表组中的ID以匹配报表中文本框中的值(这可能很重要)。

我得到的错误看起来像:不支持JOIN表达式。 “看起来”,因为我使用的是法语版的Access,所以这是一个基本的翻译...

我做错了什么?

2 个答案:

答案 0 :(得分:2)

我认为你需要CROSS JOIN表Groups,然后将T4.ID放在查询的WHERE子句中,但这并不能解决可能存在的关系在T4.ID和用于加入其他表的其他ID列之间:

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
CROSS JOIN Groups AS T4 
WHERE T4.ID = " & (Me.Texte423) & "
ORDER BY Categories, T1.Questions;

如果ID和AllQuestions之间存在关联,那么您需要按以下方式修改查询:

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
INNER JOIN Groups AS T4 ON T1.{Group ID Relation} = T4.ID
WHERE T4.ID = " & (Me.Texte423) & "
ORDER BY Categories, T1.Questions; 

答案 1 :(得分:0)

你做不到。但是您可以修改查询的SQL。将其设置为:

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
INNER JOIN Groups AS T4 ON  T4.ID = {0}
ORDER BY Categories, T1.Questions;

然后在需要时设置/修改SQL:

MyQdy.SQL = Replace(SQL, "{0}", Me!Texte423.Value)