Solved

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

Posted on 2011-02-15
5
831 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 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 84
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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