The below should do the trick - I didn't have time to check it but give it a
shot.
 <cfquery name="users_adverts" datasource="localads">
SELECT ID,email,subject,paid FROM advert_details
WHERE featured = No
AND (
<cfloop index="i" list="#client.troll#">
ID <> #i# OR
</cfloop> 1=2)
</cfquery>


-----Original Message-----
From: W Luke [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 01, 2001 9:48 AM
To: CF-Talk
Subject: Excluding IDs in queries


Hello.

I'm trying to exclude an ID from the WHERE in a query, by looping through a
list, but it's causing a lot of headaches.  The list contains delimited list
of IDS (120,145,987,564 etc)

 <cfquery name="users_adverts" datasource="localads">
SELECT ID,email,subject,paid FROM advert_details
WHERE featured = No
AND (
<cfloop index="i" list="#client.troll#">
OR ID <> #i#
</cfloop>)
</cfquery>

I know the above is glaringly wrong, but I've tried everything - is it the
positioning of ANDs and ORs?

Any advice would be muuuch appreciated.

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