Two ways to do what you want, grouping or query of query.
Grouping:
<cfquery name="getLinks" datasource="#REQUEST.dataSource#">
SELECT *
FROM links
ORDER BY category
</cfquery>
<cfoutput query="getLinks" group="category">
A link in category: #getLinks.category#<br />
<a href="#getLinks.link#">#getLinks.title#</a><br />
#getLinks.description#
</cfoutput>
QofQ:
<cfquery name="getLinks" datasource="#REQUEST.dataSource#">
SELECT *
FROM links
ORDER BY category
</cfquery>
<cfquery name="cfLinks" datasource="...">
SELECT *
FROM getLinks
WHERE category = 'CF'
</cfquery>
<cfoutput query="cfLinks">
<a href="#cfLinks.link#">#cfLinks.title#</a><br />
#cfLinks.description#
</cfoutput>
Adrian
> -----Original Message-----
> From: John Barrett [mailto:[email protected]]
> Sent: 21 August 2009 02:00
> To: cf-newbie
> Subject: Re: cfquery output+WHERE
>
>
> Hi Pual,
> Yeah I know that works, but I wanted to use the same cfquery for multi
> outputs but to change the where clause for different categories.
> I only have about 7 categories, and so this will not be too bad. I am
> thinking that maybe I can put all the different quries in a cfc and
> then invoke it.
>
> Thanks so much for your help`-`
> John
> On Aug 20, 2009, at 2:52 PM, Paul Kukiel wrote:
>
> >
> > Hi John,
> >
> > Try this:
> >
> > <cfquery name="getLinks" datasource="#REQUEST.dataSource#">
> > SELECT *
> > FROM Links
> > WHERE Category = "CF"
> > </cfquery>
> >
> > <cfoutput query="getLinks" >
> > <a href="#getLinks.link#">#getLinks.title#</a> <br />
> > #description#
> > </cfoutput>
> >
> > Paul
> >
> > -----Original Message-----
> > From: John Barrett [mailto:[email protected]]
> > Sent: Thursday, August 20, 2009 8:39 PM
> > To: cf-newbie
> > Subject: cfquery output+WHERE
> >
> >
> > Can I do something like this? I get an error saying WHERE is not
> > allowed?
> > Now I know it is allowed in the cfquery, but if I want to use the
> > WHERE
> > clause in the cfquery output are there any options?
> >
> > Thanks,
> > John
> >
> > <cfquery name="getLinks" datasource="#REQUEST.dataSource#">
> > SELECT *
> > FROM Links
> > </cfquery>
> >
> > <cfoutput query="getLinks" WHERE Category = "CF">
> > <a href="#getLinks.link#">#getLinks.title#</a> <br />
> > #description#
> > </cfoutput>
> >
> >
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4740
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15