2016-04-27 50 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;