Not sure I got you right, but look:

<cfquery>
select *
from tbl
where <cfloop index="item" list="#csvList#">
#csvList# Like '%#searchstring#%' OR
</cfloop> 1=2

</cfquery>

The last 1=2 is to "seal" the cfquery's last OR
1=2 will produce no other results..


Thanks,

Michael

----- Original Message -----
From: "Paul Sinclair" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, June 13, 2001 4:17 PM
Subject: SQL: Comparing value against a list of values


> I have a table with a field that contains a comma delimited list of
values,
> such as:
>
> 10,11,21,100
>
> In doing a <cfquery> against the table, I want to select records where one
> or more of the values in this list of values matches a value in the WHERE
> clause of my sql query. For example:
>
> select *
> from tbl
> where csvList = '%1%'
>
> The problem is that the above select statement will select ANY record that
> has '1' in the field no matter what the "true" values in the field are
> (i.e., 1 is "LIKE" 10,11,21,100).
>
> How do I make the select query compare '1' against '10', and '1' against
> '11' and '1' against '21', and '1' against '100'.
>
> Thank you for help.
>
> Regards,
> Paul Sinclair
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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