> here is what u should dooooo. use the valuelist function in 
> the second query. it basically is a comma delimited value of 
> all the data from the first query. see, uonly run 2 queries 
> in all! :) teeheeehehee
> 
> 
> <CFQUERY name="firstquery">
>       SELECT   Maincat.id
>       FROM Maincat
>       WHERE  Maincat.userid = #userid#
> </CFQUERY>
>       <CFQUERY name"getSubcats">
>               SELECT count(*) as subcats
>               FROM tblsubcats
>               WHERE tblsubcast.maincatid IN 
> ('#ValueList(firstquery.id)#')
>       </CFQUERY>

If you're only using the first query to retrieve a list used in the second
query, you don't need two queries:

<cfquery name"getSubcats">
        SELECT count(*) as subcats
        FROM tblsubcats
        WHERE tblsubcast.maincatid IN 
                (SELECT   Maincat.id
                 FROM Maincat
                 WHERE  Maincat.userid = #userid#)
</cfquery>

All other things being equal, you should use as few queries as possible.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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