“不支持连接表达式” - 需要有关Microsoft Access查询的帮助

时间:2017-09-23 11:50:51

标签: sql ms-access

我需要一些帮助才能使以下SQL代码工作:

SELECT MemberData.MemberID, Transaction.TrxID, Transaction.Date, 
Transaction.GroupID, TransactionDetails.CashIn, TransactionDetails.CashOut

FROM [Transaction] 
INNER JOIN (MemberData LEFT JOIN TransactionDetails 
            ON MemberData.[MemberID] = TransactionDetails.[MemberID]) 
ON Transaction.[TrxID] = TransactionDetails.[TrxID];

以下错误说明不断弹出:

  

不支持加入表达式“

我做错了什么,如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

我无法确定错误的确切来源,但对大多数Join expression not supported错误的简单修复是一次执行一次连接,并使用子查询。

 SELECT MemberData.MemberID, T.TrxID, T.[Date], 
T.GroupID, T.CashIn, T.CashOut
FROM (
    SELECT [Transaction].TrxID, [Transaction].Date, [Transaction].GroupID, TransactionDetails.CashIn, TransactionDetails.CashOut, TransactionDetails.[MemberID]
     FROM [Transaction] 
     LEFT JOIN TransactionDetails  ON [Transaction].[TrxID] = TransactionDetails.[TrxID]
) AS T
INNER JOIN MemberData ON MemberData.[MemberID] = T.[MemberID];

答案 1 :(得分:0)

@Poomind @Erik von Asmuth只需将INNER JOIN更改为RIGHT JOIN您可以尝试将下一个SQL语句粘贴到新查询中。

SELECT MemberData.MemberID, T.TrxID, T.[Date], T.GroupID, T.CashIn, T.CashOut 
FROM (SELECT [Transaction].TrxID, [Transaction].Date, [Transaction].GroupID,
             TransactionDetails.CashIn, TransactionDetails.CashOut, TransactionDetails.[MemberID]
     FROM [Transaction] 
     LEFT JOIN TransactionDetails  ON [Transaction].[TrxID] = TransactionDetails.[TrxID])
 AS T RIGHT JOIN MemberData ON MemberData.[MemberID] = T.[MemberID];

当我在示例数据库中保存此查询时,ms-access(版本2003)将其更改为以下SQL语句。所以,不要担心这是否会发生在你身上。

SELECT MemberData.MemberID, T.TrxID, T.[Date], T.GroupID, T.CashIn, T.CashOut
FROM [SELECT [Transaction].TrxID, [Transaction].Date, [Transaction].GroupID, TransactionDetails.CashIn, TransactionDetails.CashOut, TransactionDetails.[MemberID]
     FROM [Transaction] 
     LEFT JOIN TransactionDetails  ON [Transaction].[TrxID] = TransactionDetails.[TrxID]
]. AS T RIGHT JOIN MemberData ON MemberData.[MemberID] = T.[MemberID];