PDA

View Full Version : how to get unmatched records from database tables ?



gopi09_m
01-18-2012, 11:56 PM
Hi

The below query returns the matched records for left table (Sheet1 ):

"SELECT [Sheet1$A1:A24].ColA FROM [Sheet1$A1:A24] where [Sheet1$A1:A24].ColA in (SELECT Distinct([Sheet1$A1:A24].ColA) FROM [Sheet1$A1:A24],[Sheet2$A1:A23] where [Sheet1$A1:A24].ColA = [Sheet2$A1:A23].ColB)"

But the above query when used with not in never returns me the unmatched records from left table (Sheet1)

"SELECT [Sheet1$A1:A24].ColA FROM [Sheet1$A1:A24] where [Sheet1$A1:A24].ColA not in (SELECT Distinct([Sheet1$A1:A24].ColA) FROM [Sheet1$A1:A24],[Sheet2$A1:A23] where [Sheet1$A1:A24].ColA = [Sheet2$A1:A23].ColB)"

when i ran the similar query in the Query editor of SQL it retuns me the unmatched records from the left table.

Any suggestions ?
My main intention is to get the unmatched records for first table as well as second table separately.