Solved

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

Posted on 2011-02-15
5
906 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 34900613
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
ID: 34901012
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34901113
can you upload a copy of the db.
0
 
LVL 85
ID: 34902005
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
ID: 34906477
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

627 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