I have a query 'Query1' which gives a list on pay_codes & names,
and another query 'Query2' which gives a slightly different list of pay_codes & names.
I want to know which pay_code & names are in one table but not in the other.
Searching, I have found the following.
query = "SELECT MIN(TableName) as TableName, pay_code, name" & _
" FROM (" & query1 & " UNION ALL " & query2 & ") AS tmp" & _
" GROUP BY pay_code, name HAVING COUNT(*) = 1 ORDER BY pay_code"
This gives:
Table B, A002, name1
Table B, A079, name2
Table A, A085, name3
Table A, A095, name4
It gives a list of the names in query1 but not in query2, AND the names in query2 but not in query1.
I only want:
Table B, A002, name1
Table B, A079, name2
If I add "WHERE TableName = 'Table B'" I get the whole table.
How can I get hjust the names I want?
Thanks.


Reply With Quote

