Solved

How do I combine two queries in MS Access so that resulting records from query one are removed from query two?

Posted on 2008-10-28
6
191 Views
Last Modified: 2012-05-05
I have two queries in MS Access.  They both return an ID (primary key) for an individual.  How do I create a 3rd query that returns the ID from query 1 only if it does not exist in query 2?
0
Comment
Question by:rporter45
[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
  • 3
  • 3
6 Comments
 
LVL 42

Expert Comment

by:dqmq
ID: 22824679
Select * from query1 Q1 where Q1.id not in (select id from query2)
0
 

Author Comment

by:rporter45
ID: 22824816
is that exact sybtax other than the query names and fields?
0
 

Author Comment

by:rporter45
ID: 22825029
This does'nt work.  It is asking me for a parameter value for Query1.

SELECT DISTINCT [Query1].ID AS Expr1
FROM [Query1] AS Q1
WHERE (((Q1.ID) Not In (SELECT [Query2].ID from [Query2])))
ORDER BY [Query1].ID;
0
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 22825850
>is that exact sybtax

No, it's the general form.  Take this:

SELECT DISTINCT [Q1].ID AS Expr1
FROM [Query1] AS Q1
WHERE (((Q1.ID) Not In (SELECT [Q2].ID from [Query2] AS Q2)))
ORDER BY [Q1].ID;


And replace FROM [Query1] and FROM [Query2] with the FROM clauses from your original queries
0
 

Author Comment

by:rporter45
ID: 22825954
It is still asking me for a parameter value?  Why?
0
 
LVL 42

Expert Comment

by:dqmq
ID: 22827535
because one of the names within square brackets  is incorrect.  
0

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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