----- Original Message -----
From: Michael Dinowitz
To: CF-Talk
Sent: Sunday, August 08, 2004 6:56 PM
Subject: Re: SELETCT IN (LISTOFSTRINGS)
When you have a singel value, the IN looks like this:
In ('value')
When you have multiple values, it looks like this:
In ('value1,value2,value3')
What you want is to use the ListQualify() function to set each element in the list to be within single quotes (like so)
In ('value1','value2','value3')
To do this, use the function like so:
In (#ListQualify(userlist, "'", ",","all")#
This says to take the list userlist and place a single quote before and after each list item where a comma is the list delimiter.
If the list will also contain numbers, use the 'char' rather than the 'all' modifier.
> I don't know whats going on here...but as long as the list has only
> one item in it, it works... once it gets more than one it bombs.
>
> <cfset UserList = "Userone,UserTwo,UserThree">
>
> <cfquery name="registeredusers" datasource="MyDSN">
> select Username, UserID from tbl__Users
> where Username IN ('#userlist#')
> order by Username
> </cfquery>
>
>
> does each item need single quotes and take the single quotes out of
> the query???
> if i hardcode the list in the query it needs single quotes around each
> one so Im assuming thats it. Is there an easy way to surrond each item
> with single quotes if thats the
case?
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]