• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Merge two query results

Guest
Nov 14, 2006 Nov 14, 2006

Copy link to clipboard

Copied

Is it possible to merge 2 query results?

I have a function that returns a querey result.

< CFSET temp = query1>
<CFSET FNCTransfers = temp>

Now I want to change the query to return a merged query result

< CFSET temp = query1>
<CFSET temp2 = query2>

Is it possible to merge the two results?

Some thing like this (I know that it cannot be done like this)
<CFSET FNCTransfers = temp1 & temp2>

Maby it should be a union and query of query?


TOPICS
Advanced techniques

Views

669

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 14, 2006 Nov 14, 2006
UNION could be the way to go. the query results will have to match up
between the 2 queries (field data types need to match for both queries)

<cfquery name="qryMergedQueries" dbtype="query">
SELECT * FROM query1
UNION
SELECT * FROM query2
</cfquery>


kruse wrote:
> Is it possible to merge 2 query results?
>
> I have a function that returns a querey result.
>
> < CFSET temp = query1>
> <CFSET FNCTransfers = temp>
>
> Now I want to change the query to return a merged query result
>
> <...

Votes

Translate

Translate
New Here ,
Nov 14, 2006 Nov 14, 2006

Copy link to clipboard

Copied

You will most likely find trying to use Query of Query very problematic. I reccommend that you actually write a SQL statement to do the union at the DB end.

I know that it seems a bit crappy, but i think it will help you maintain your sanity.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 14, 2006 Nov 14, 2006

Copy link to clipboard

Copied

The best way to achieve your goal depends on what it is. Your question is very general.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 14, 2006 Nov 14, 2006

Copy link to clipboard

Copied

UNION could be the way to go. the query results will have to match up
between the 2 queries (field data types need to match for both queries)

<cfquery name="qryMergedQueries" dbtype="query">
SELECT * FROM query1
UNION
SELECT * FROM query2
</cfquery>


kruse wrote:
> Is it possible to merge 2 query results?
>
> I have a function that returns a querey result.
>
> < CFSET temp = query1>
> <CFSET FNCTransfers = temp>
>
> Now I want to change the query to return a merged query result
>
> < CFSET temp = query1>
> <CFSET temp2 = query2>
>
> Is it possible to merge the two results?
>
> Some thing like this (I know that it cannot be done like this)
> <CFSET FNCTransfers = temp1 & temp2>
>
> Maby it should be a union and query of query?
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 14, 2006 Nov 14, 2006

Copy link to clipboard

Copied

I had two different queryes getting internal transgers in a company and external transfers in/out of a company and then I would show a merged list of this two results.
The two queryes vere very complex and therfore I would not merge the two queryes into one query.

The query of query aproach worked very well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

LATEST

Merging pag.ibig contribution

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation