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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subset of the overlap of two queries

Status
Not open for further replies.

EnemyGateIsDown

Technical User
Oct 3, 2002
235
GB
Hi

I have two queries that return the same columns and I want use them as the source for a third query that only shows the rows that appear in both sets.

Union shows all the rows from both.. I want sort of "subset" the queries together to show only the rows that appear in both queries...

Any ideas anyone?

Thanks in advance for any help.

Cheers,

Chris
 
well, are the results from the 2 seperate queries distinct?

if so then you can just union the 2 queries, and then select the records that appear more than once...

SELECT * FROM qry1 INNER JOIN qry2 ON qry1.key = qry2.key
WHERE COUNT(qry1.key) > 1;
 
Thanks Crowley16 the only thing is that I need to run this from ASP and need to pass variables into the two source queries. Will the JET engine allow me to expand query1 and query2 into sub selects?

Thanks

Chris
 
Wouldn't it be more efficient to use an Inner Join with the two queries directly?

Select A.*
From QueryA as A Inner Join QueryB as B on A.Key1=B.Key1

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top