Deselect (Not delete) common records of two query

A

Azad,DH, BD

Dear Experts,

I'm badly in need of your help. pls, help me. I've 2 query and finally I'd
like to make the 3rd query that will only select all records except the
common records of both query. How can I do that?

Waiting for your response.


Thanks.
 
J

John Spencer

Generically, you could use a union query to get the records not in one
query (unmatched query wizard) and not in the other query. Assuming
that the fields returned by the two queries were the same and in the
same order the UNION query might look like the following.

SELECT Query1.*, "In Q1 Only" as Source
FROM Query1 LEFT JOIN Query2
ON Query1.MatchField = Query2.Matchfield
WHERE Query2.MatchField is Null
UNION ALL
SELECT Query2.*, "In Q2 Only" as Source
FROM Query2 LEFT JOIN Query1
ON Query2.MatchField = Query1.Matchfield
WHERE Query1.MatchField is Null


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top