<cfquery name="getarticleCats" dsn=dsn>
Select ID
,Name
,(select count(*) from Articles where A_Cat = ArticleCats.ID) as
CountItems
From ArticleCats
</cfquery>
and then CountItems will tell you how many times each one is used. I have
used this technique with Access, SQLServer and Oracle. Works good and fast.
> -----Original Message-----
> From: Cyrill Vatomsky [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 24, 2000 12:50 PM
> To: CF-Talk
> Subject: looping through queries
>
>
> I have two tables: Articles, ArticleCat(egorie)s. At some point I want to
> list all categories and allow checkboxes for multiple deletes,
> but only when
> a category is empty (no articles).
>
> I want to loop through a query of ArticleCats and test if there
> are articles
> under that category. The only thing I can think of is to run query each
> iteration of the loop, which does not sound right.:
>
> <cfquery name="getarticleCats" dsn=dsn>
> Select ID, Name
> From ArticleCats
> </cfquery>
>
> <cfloop query="getArticleCats">
> <cfquery name="isAssigned" maxrows=1>
> Select ID from Articles
> Where A_Cat=#getArticleCats.ID#
> </cfquery>
> <cfif NOT isAssigned(RecordCount)=0>
> <cfset deleteOK=False>
> </cfif>
>
> This sounds like a huge burden. Is there another way to do it?
>
> ------------------------------------------------------------------
> ------------------------------
> Archives: http://www.mail-archive.com/[email protected]/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
> or send a message with 'unsubscribe' in the body to
> [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]