Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common results between two queries 1

Status
Not open for further replies.

jason246day

Programmer
Jul 9, 2003
127
0
0
US
I have 2 queries that are independent of each other, qryTemp1 and qryTemp2. Both of them return a list of policy numbers, but both have different criteria that they are searching for. I am trying to find a way to return the policy numbers that are found in the results of both of these queries.

I looked into using an INNER JOIN, but that looked like it needed to be used on a WHERE clause, as opposed to using the 2 saved queries directly.

Does anyone know of a way to do this? Thanks ahead of time.
 
How about
Code:
(Select * From qryTemp1)

UNION ALL

(Select * From qryTemp2)

The two queries need to have the same fields in the same order.
 
I've already tried that. It gives me all the results from both queries. I am looking for the results that are common to both.
 
Sorry. I misunderstood.

Code:
Select *

From qryTemp1 Q1 INNER JOIN qryTemp2 Q2 
     ON Q1.PolicyNumber = Q2.PolicyNumber
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top