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

Combining two queries to one

Guest
Aug 08, 2006 Aug 08, 2006
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

TOPICS
Database access
9.4K
Translate
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 ,
Aug 08, 2006 Aug 08, 2006
LATEST
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.
Translate
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