You can do this with two queries.

<cfquery name="getallarticleCats" dsn=dsn>
Select catID, Name
>From ArticleCats
</cfquery>

<cfquery name="getassignedcats" dsn=dsn>
SELECT catID
FROM ArticleCats
WHERE catid NOT IN (Select Distinct catID 
                    from Articles)
</cfquery>

Then when you're outputting

<cfif getallarticlecats.catid in ValueList(getassigncats.catid)>
<cfset deleteok = "False">
</cfif>

HTH,
--K

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

Reply via email to