Question
How to create a varchar list?
I need to create a list like this: '00','11','33','44'
When I use ValueList or ListAppend I got '00,11,22,33,44'
My simple codes are as follow:
query name="test" datasource="test">
select empID from Employers
</cfquery>
I tried: <CFSET EmpIDList=ValueList(test.EmpId)>
OR
<cfset MyList="">
<cfloop query="test">
<cfset MyList=#ListAppend(MyList, 'EmpID')>
</cfloop>
Both techniques creates a list that looks like : ' 00,11,22,33,44,55,66' which I can't use this list in the
select * from table where IDList IN ( '00,11,22,33,44,55,66')
Can anyone tell me how can I produce a list with each ID being surrounded by a single quote like ' 00 ', ' 22 ', ' etc so i can use the list on the select statement?
When I use ValueList or ListAppend I got '00,11,22,33,44'
My simple codes are as follow:
query name="test" datasource="test">
select empID from Employers
</cfquery>
I tried: <CFSET EmpIDList=ValueList(test.EmpId)>
OR
<cfset MyList="">
<cfloop query="test">
<cfset MyList=#ListAppend(MyList, 'EmpID')>
</cfloop>
Both techniques creates a list that looks like : ' 00,11,22,33,44,55,66' which I can't use this list in the
select * from table where IDList IN ( '00,11,22,33,44,55,66')
Can anyone tell me how can I produce a list with each ID being surrounded by a single quote like ' 00 ', ' 22 ', ' etc so i can use the list on the select statement?
