[thelist] [CF & SQL] Passing ColdFusion List Variable into SQL INStatement
Chris Hayes
chris at lwcdial.net
Thu Jul 6 11:31:56 CDT 2006
----- Original Message -----
From: "Minh Lee Goon" <evolt at goonies.info>
> SELECT *
> FROM TableName
> WHERE ColumnName IN ('#ListName#')
>
> I've always had good luck with statements like this, so I'm baffled now.
> I did try to hard-code the list elements into the query statement and
> that worked just fine. Do I have to replace the list elements to add the
> single quotes around them?
>
Yes, what you end up with must look like :
SELECT *
FROM TableName
WHERE ColumnName IN ('name1', 'name2', 'name3')
So if your list is not already qualified , use
ListQualify(list, qualifier)
like this...
SELECT *
FROM TableName
WHERE ColumnName IN (#ListQualify(ListName#, "'")#)
*Note the "'" is double-single-double quotes " ' "
HTH
More information about the thelist
mailing list