I hope some one can help me with this problem, Hopefully a small one )


I am doing a count with a query,  but right now am looping through it to
count each different category,  Is there a way to do count on all categories
running the query only once?  this would save a lot of processing time for
the page, as there can be anywhere from 1 to 5000 categories to loop through
depending on what the user wants in the report.  example code below:

First query gets all the Main categories a user is associated with then loop
through second query to get all the subcategories associated with each main
category.  Would like to only have to run the counting query once, is this
possible?


<CFQUERY name="firstquery">
        SELECT   Maincat.id
        FROM Maincat
        WHERE  Maincat.userid = #userid#
</CFQUERY>

<CFLoop query="firstquery">
        <CFQUERY name"getSubcats">
                SELECT count(*) as subcats
                FROM tblsubcats
                WHERE tblsubcast.maincatid = #firstquery.id#
        </CFQUERY>
</CFLOOP>
 

Thanks for any help
Rodney


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to