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
188 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
average of calculation (TSQL) 4 33
Stored Proc - Rewrite 42 71
How to create XML in below format from SQL Query in SQL Server? 3 43
Sql case statement to calculate totals 5 32
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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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 …

685 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