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
187 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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