Sub Queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have mutiple queries (ie. Query1a, Query1b...QueryFinal) where QueryFinal
connects Query1a and 1b together. I want to be able to do this all in one
query if possible. The only way to do this (I believe) is to go into the SQL
View and build subqueries

Does anyone know a good site explaining this? I know it should look
something like this:

Select A.Field, B.Field
(
Select .... Query1a stuff
(.....
)A

Select .... Query2a stuff
(.....
)B
)
GROUP BY...
 
Dear James:

Your question is not sufficiently detailed to let me know what you are
constructing.

If the queries all have the same exact columns in them, then a UNION may be
what you wish to see. I would construct such a query like this:

SELECT "1a" AS QSource, * FROM Query1a
UNION ALL
SELECT "1b" AS QSource, * FROM Query1b
..
..
..

If you want to show columns from each of the queries across a row, then some
sort of JOIN is in order. You give no information as to how rows from one
table are related to rows from another, and I don't feel this is probably
what you're after.

Please let me know if this helped, and how, and any questions you may still
have.

Tom Ellison
 
You don't have anything in the SQL to "connect" Query1a and Query1b. How
are the rows between these derived Tables related?

Tom is probably correct in guessing that you want to use a Union Query.

I find the book "SQL Queries for Mere Mortals" by Hernandez & Viescas is
very useful in doing SubQueries / complex stuff in JET SQL.
 
Back
Top