0
Combining two queries to one

/t5/coldfusion-discussions/combining-two-queries-to-one/td-p/10522
Aug 08, 2006
Aug 08, 2006
Copy link to clipboard
Copied
I have two queries and I would like to output the results as
one and sort by Name ASC
Any help would be great thanks
Any help would be great thanks
TOPICS
Database access
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
LATEST
/t5/coldfusion-discussions/combining-two-queries-to-one/m-p/10523#M1075
Aug 08, 2006
Aug 08, 2006
Copy link to clipboard
Copied
Either use union in your SQL query or use Coldfusion to
combine exisitng queries and create a new query resultset.
Something like this:
<CFQUERY NAME="getDetailsQuery1" DATASOURCE="#DSNNAME#">
SELECT * FROM getDetailsA
</CFQUERY>
<CFQUERY NAME="getDetailsQuery2" DATASOURCE="#DSNNAME#">
SELECT * FROM getDetailsB
</CFQUERY>
<CFQUERY NAME="getDetails" DBTYPE="query">
SELECT * FROM getDetailsQuery1
UNION
SELECT * FROM getDetailsQuery2
ORDER BY Name ASC
</CFQUERY>
Hope this helps!
Cheers / Manu.
Something like this:
<CFQUERY NAME="getDetailsQuery1" DATASOURCE="#DSNNAME#">
SELECT * FROM getDetailsA
</CFQUERY>
<CFQUERY NAME="getDetailsQuery2" DATASOURCE="#DSNNAME#">
SELECT * FROM getDetailsB
</CFQUERY>
<CFQUERY NAME="getDetails" DBTYPE="query">
SELECT * FROM getDetailsQuery1
UNION
SELECT * FROM getDetailsQuery2
ORDER BY Name ASC
</CFQUERY>
Hope this helps!
Cheers / Manu.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

