Solved

What is the opposite to an "Union All" clause in MS Access?

Posted on 2011-02-15
5
790 Views
Last Modified: 2012-05-11
Hi All!

I have two queries with the same fields.  The first one returns 1000 records; the second one, 100 records whose Id's intersect with some of the first query.  What I want to do is to perform a query that shows the records of the first query MINUS the ones of the second query.  In fact, what I'm looking for here is the opposition of an Union All clause.

I tried this ("Not In" clause) before, but it didn't return any record.  Weirdly enough, an "In" clause works fine, nut not a "Not In" clause.  

SELECT [Équipement total].MODEL_NO
FROM [Équipement total]

where  [Équipement total].MODEL_NO

not IN

(SELECT [Équipement à exclure].MODEL_NO
FROM [Équipement à exclure])
order by MODEL_NO

Would anyone have a solution to this simple problem?

Thanks!

Francis
0
Comment
Question by:AlainSt-Pierre
  • 2
  • 2
5 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
copy and paste this to the SQL view of the query

SELECT [Équipement total].MODEL_NO
FROM [Équipement total] Left Join [Équipement à exclure]
On [Équipement total].MODEL_NO= [Équipement à exclure].MODEL_NO
Where [Équipement à exclure].MODEL_NO is null
0
 

Author Comment

by:AlainSt-Pierre
Comment Utility
Hi capricorn,

I'm glad to read from you once again!  Unfortunately your query isn't returning any result. FYI I joined the results of my two queries.

Thank you!

Francis
My-Queries.docx
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
can you upload a copy of the db.
0
 
LVL 84
Comment Utility
Try a Right Join:

SELECT [Équipement total].MODEL_NO
FROM [Équipement total] RIGHT JOIN [Équipement à exclure]
On [Équipement total].MODEL_NO= [Équipement à exclure].MODEL_NO
Where [Équipement total].MODEL_NO is null
0
 

Author Comment

by:AlainSt-Pierre
Comment Utility
Cap's query was just fine.  I closed the db, reopened it then it worked fine.  It seems like the damn thing's got a hard time saving new modifications.  Thanks a lot guys!!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now