macromedia.coldfusion.advanced_techniques
[Top] [All Lists]

Re: Query of Queries on 2 datasources

Subject: Re: Query of Queries on 2 datasources
From: "MIGhunter"
Date: Sun, 22 Feb 2009 00:28:26 +0000 UTC
Newsgroups: macromedia.coldfusion.advanced_techniques

I get a lot of help from http://easycfm.com.  One of the guys there posted a 
http://www.bealearts.co.uk/blog/2007/06/20/how-to-do-an-outer-join-in-query-of-q
ueries/ on how to do outter joins on QofQs.  That way you get all the 
information from both tables, even if they aren't the same.

 <cfquery name="joinQuery" dbtype="query" >
 SELECT *
 FROM QueryB
 WHERE QueryB.ID = -1
 </cfquery>

 <cfset QueryAddRow(joinQuery) />

 <cfquery name="result" dbtype="query" >
 SELECT *
 FROM QueryA, QueryB
 WHERE QueryA.ID = QueryB.ID

 UNION

 SELECT QueryA.*, joinQuery.*
 FROM QueryA, joinQuery
 WHERE QueryA.ID NOT IN (#ValueList(QueryB.ID)#)
 </cfquery>


<Prev in Thread] Current Thread [Next in Thread>