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
189 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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
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

Technology Partners: 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
SQL Query Grouping Question Record Inserts 9 63
SQL - Simple Pivot query 8 37
Get data from two MySQL tables 6 65
Any benefit to adding a Clustered index here? 4 37
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 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