[thelist] CFMX Nested Queries

Judah McAuley judah at wiredotter.com
Fri Feb 4 13:10:28 CST 2005


Actually, its not the query nesting that's a problem, its the nesting of 
the <cfoutput> tag. If you change the inside <cfoutput> (the one where 
you try and output qfeed) to a <cfloop type="query"> you don't have to 
use the include. Since the variable is already inside a <cfoutput>, the 
variable will be evaluated.

Judah

Russ wrote:
> Nothing like sending a post to a list to get the answer to smack you in
> the head...
> 
> <tip type="Nested Queries In ColdFusion MX" author="Russ Unger">
> Surprise! ColdFusion does not allow for "direct" nesting of queries.
> 
> In order to achieve nested queries, you can create your query:
> 
> //Query the RSS table for the ID, Title, etc.
> <cfquery name="qRSS" datasource="#dns#">
> SELECT *
> FROM tblRSS
> ORDER BY rssID ASC
> </cfquery>
> 
> And then when you want to "nest a query" you need to put your nested
> query in an include file and call it that way.
> 
> Such that:
> 
> <cfinclude template="qFeed.cfm">
> 
> ******************************
> INCLUDE FILE
> ******************************
> 
> <cfquery name="qFeed" datasource="#dns#" maxrows="5">
> SELECT *
> FROM tblFeed
> WHERE tblFeed.rssID=#qRSS.rssID#
> ORDER BY feedID ASC
> </cfquery>
> <cfoutput query="qFeed">
>   	<tr>
> 	<td align="center">
>     
> 	<ul>
>       <li><a href="#qFeed.feedLink#"
> target="_blank">#qFeed.feedTitle#</a>
>       </li>
>     </ul></td>
>   </tr>
> </cfoutput>
> 
> </tip>
> 
> 
> 
>>-----Original Message-----
>>From: thelist-bounces at lists.evolt.org 
>>[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Russ
>>Sent: Tuesday, February 01, 2005 6:50 PM
>>To: thelist at lists.evolt.org
>>Subject: [thelist] CFMX Nested Queries
>>
>>
>>Grr, sorry...
>>
>>I'm attempting to pull some information from 2 tables in my database
>>(where I'm storing my RSS feed information):
> 
> 
> 



More information about the thelist mailing list