Ok when I use your statement & also when I add UNION ALL to the query, I get
the same results - all the records from both tables with identifiers. That's
cool, but how do I select:
1) all records that have a match by name & delete (I already have a
duplicates query from both tables)
You can't delete or otherwise update a Union query at all. You may be
able to use a Subquery, but it'll be complicated - how will you decide
which record to delete?
A better solution might be to create a new table with a unique Index
on the columns which constitute a duplicate; run Append queries from
both the PPO and MHP tables into this new table. Only one instance of
each will be saved, you'll get a warning message that "x records were
not appended due to key violations" - that's your dups.
2) all records that are in "PPO" that are not in "MHP"
A UNION query is inappropriate here. Use a Frustrated Outer Join query
instead:
DELETE PPO.*
FROM PPO LEFT JOIN MHP
ON PPO.[LAST_NAME] = MHP.[DRLNAME]
AND PPO.[FIRST_NAME] = MHP.[DRFNAME]
WHERE MHP.LAST_NAME IS NULL;
Note that this will - again - delete records for MULTIPLE PEOPLE if
they happen to share the same name. This is quite common; I know three
gentlemen named Fred Brown, right here in little Parma, Idaho.
John W. Vinson[MVP]