Joining 2 Tables

D

Dar

I have 2 tables: 'tblAssetCatLinkBackup012501' and 'tblAssetCatLink'. Both
tables have a field called 'asset'. I want to see which assets in the
'tblAssetCatLinkBackup012501' table are NOT in the 'tblAssetCatLink' table.
My query is below, but the 'NOT IN' in the WHERE clause is not working. Am I
writing this correctly?

Thanks for any help.


select asset
from tblAssetCatLinkBackup012501
where asset NOT IN (select asset from tblAssetCatLink);
 
G

Gerald Stanley

It looks fine. If it is not giving the results that you are expecting,
another way of writing this query would be

SELECT T1.asset
FROM tblAssetCatLinkBackup012501 AS T1 LEFT JOIN tblAssetCatLink AS T2 ON
T1.asset = T2.asset
WHERE T2.asset IS NULL;

Hope This Helps
Gerald Stanley MCSD
 
Top