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

Double Subquery SQL syntax

Status
Not open for further replies.
Jul 6, 2005
52
GB
I’m trying to run a query that is based on a subquery that is based on another subquery, i.e. 3 queries in total. I can get the SQL of the first two subqueries to work but am not sure of the syntax for the last query that provides the final result. The SQL for the first 2 subqueries which works fine, follows the pattern below:

SELECT abc.field
FROM [subquery sql]. AS abc

Can anyone suggest how to incorporate that into a final query? I’ve tried this:

SELECT xyz.field
FROM [SELECT abc.field FROM [subquery sql]. AS abc]. AS xyz

but it doesn’t work.
 
Try Creating the subquery as a seperate external query and save it in MS-Access.

In your SELECT Statement, instead of actually writing the subquery just you the MS-Access query name.

i.e., as per your SELECT Statement

SELECT xyz.field
FROM [SELECT abc.field FROM <<Query Name>> AS abc]. AS xyz

Here <<Query Name>> is the query that is created and stored in Access which has the Subquery SQL as its SELECT Statement.

In the same way You can create 2 external queries and totally elimnate even the first subquery.

Regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top