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
184 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now