Use NOT IN

WHERE featured = No AND
                ID NOT IN (#ListofIDs#)


----- Original Message -----
From: "W Luke" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Sunday, April 01, 2001 9:48 AM
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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to