Board index » delphi » Queries' columns union

Queries' columns union

Hi there!
I need to join output of multiple quries together, but not their rows -
their columns! Is there a simple way to do this? I think, it's not that rare
task, but I just can't contrive anything interesting
 

Re:Queries' columns union


You need to create another SQL Query, linking the results from the
others. Assuming that you have 2 queries, 'query1' and 'query2', and
you want to link the field 'myField', the SQL would be something like:

SELECT a.*, b.*
FROM query1 a, query2 b
WHERE a.myField = b.myField

Hope this helps.

On Sun, 20 May 2001 12:20:12 +0300, "NicLis" <m...@lisov.domino.dp.ua>
wrote:

Quote
>Hi there!
>I need to join output of multiple quries together, but not their rows -
>their columns! Is there a simple way to do this? I think, it's not that rare
>task, but I just can't contrive anything interesting

Re:Queries' columns union


On Sun, 20 May 2001 23:32:38 +1200, Gurble

Quote
<gurbleREM...@THISclear.net.nz> wrote:

>You need to create another SQL Query, linking the results from the
>others. Assuming that you have 2 queries, 'query1' and 'query2', and
>you want to link the field 'myField', the SQL would be something like:

>SELECT a.*, b.*
>FROM query1 a, query2 b
>WHERE a.myField = b.myField

>Hope this helps.

AFAIK, this works only if the db supports it. I don't think Paradox,
dBase, etc. do. In that case, you can save the query1 and query2
results to temp tables [use BatchMove], then query the temp tables.

All this assumes that there is some reason not to just make a single
query that produces the desired answer.

HTH,
Dan
--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control:
visit us at www.cmdcsystems.com
[SPAM block: change at to @ in my e-mail address]

Other Threads