连接操作访问中的语法错误

时间:2014-08-05 16:32:52

标签: sql ms-access

SELECT *
FROM 
(table1 FULL OUTER JOIN [FY14 PLEDGE_TOTAL]
ON table1.[Id] = [FY14 PLEDGE_TOTAL].[SID]);

我不知道为什么我在Access上遇到此错误。当我在'FROM'之后删除括号时,我在From子句上出现语法错误。请指教。谢谢!

2 个答案:

答案 0 :(得分:3)

Access不支持OUTER JOIN。您需要在数据不存在的字段上使用Is Null标准的LEFT JOIN或RIGHT JOIN变量。

以下是微软对此问题的看法:http://office.microsoft.com/en-gb/access-help/creating-an-outer-join-query-in-access-HA001034555.aspx

或者有用的东西:http://www.databasejournal.com/features/msaccess/article.php/3516561/Implementing-the-Equivalent-of-a-FULL-OUTER-JOIN-in-Microsoft-Access.htm

答案 1 :(得分:1)

MS Access不支持FULL OUTER JOIN,但可以使用UNIONLEFT JOIN RIGHT JOIN的{​​{1}}进行模拟,如下所示

SELECT *
FROM table1 t1 
LEFT JOIN [FY14 PLEDGE_TOTAL] fpt 
ON t1.[Id] = fpt.[SID]

UNION

SELECT *
FROM table1 t2 
RIGHT JOIN [FY14 PLEDGE_TOTAL] fpt1 
ON t2.[Id] = fpt1.[SID];