[thelist] CFMX Nested Queries

Russ russ at unrealisticexpectations.com
Tue Feb 1 19:46:13 CST 2005


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