2016-04-27 49 views
0

我一直在环顾四周,一直没有能够做到这一点。MS Access查询哪里不存在

我有两个查询

SELECT [Account Combination].[Account Number] & [Account Combination].[Cost Center] & [Account Combination].Amount as Val1 FROM [Account Combination]; 

和两个表产生

SELECT [Account Combination].[Account Number] & [Account Combination].[Cost Center] & [Account Combination].Amount AS Val1 FROM [Account Information] INNER JOIN ([Cost Center] INNER JOIN [Account Combination] ON [Cost Center].[Cost Center Number] = [Account Combination].[Cost Center]) ON [Account Information].[Account Number] = [Account Combination].[Account Number]; 

表1有1800行和表2有1600我想读这在表1中,并在未找到表2,200.

我已经试过了Table1不存在Tabel2,但一直无法使它正常工作,因为我总是得到语法错误。

感谢您的时间, 西蒙。

+0

标记你的问题正确,迅速得到正确答案 – Rahul

回答

4

您可以使用LEFT OUTER JOIN随着WHERE条件如下面来完成这件事

select t1.* 
from (SELECT [Account Combination].[Account Number] & [Account Combination].[Cost Center] & [Account Combination].Amount as Val1 
FROM [Account Combination]) t1 
left join (
SELECT [Account Combination].[Account Number] & [Account Combination].[Cost Center] & [Account Combination].Amount AS Val1 
FROM [Account Information] INNER JOIN ([Cost Center] INNER JOIN [Account Combination] 
ON [Cost Center].[Cost Center Number] = [Account Combination].[Cost Center]) 
ON [Account Information].[Account Number] = [Account Combination].[Account Number]) t2 
on t1.Val1 = t2.Val1 
where t2.Val1 is null;