Use <cfoutput to do al that for you: <cfoutput query="qGetEvents" group="name"> <!--- display org here ---> <cfoutput group="CategoryName"> <!--- display category here ---> <cfoutput> <!--- display event here ---> </cfoutput> </cfoutput> </cfoutput>
Use the query below. The order by is very important!! Pascal -----Original Message----- From: Michael Traher Sent: donderdag 25 september 2003 15:47 To: CF-Talk Subject: RE: How can I relate these tables in a query and loop the output? Can't figure it out... <cfquery name="qGetEvents" .......> select or.name,ec.CategoryName,ev.EventName,ev.EventDate,ev.EventDescription from organizations or, eventcategories ec, events ev where or.OrganizationID = ev.OrganizationID and ev.CategoryID = ec.CategoryID order by or.name,ec.CategoryName,ev.EventName </cfquery> <cfloop query="qGetEvents"> store name, CategoryName and EventName on first row then test if they have changed to control whether you output them or not. (cfoutput will only group on a single column I believe) </cfloop> HTH Michael Traher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm?link=i:4:138426 Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 ColdFusion MX 6.1, now 2.5 times faster. http://www.macromedia.com/software/coldfusion/productinfo/upgrade/jump/introducing.html?trackingid=ColdFusion_468x60g_HouseofFusion_carat_082803