I have a form field where user types in a comma-delimited list of values, a,b,c
. Is it possible to run a query like this?
select col1, col2
from T
where col3 IN ('a','b','c') <----- cf list from the form
I have a form field where user types in a comma-delimited list of values, a,b,c
. Is it possible to run a query like this?
select col1, col2
from T
where col3 IN ('a','b','c') <----- cf list from the form
Answering my own question (with help of comments made here)
<!---setting a list of form field values (comma-delimited as a,b,c)--->
<cfset form_style_list = #FORM.style_id#>
<!---formatting previous list--->
<cfset final_style_list = listQualify(form_style_list,"'")>
<!---using final list in a query--->
<cfquery name="q1" datasource="#REQUEST.test#">
SELECT count(*) row_count
FROM STYLE a
WHERE trim(a.style_id) in (
<cfqueryparam
value="#final_style_list#"
cfsqltype="cf_sql_char"
list="yes" />
)
</cfquery>