我有一个表单字段,其中用户键入以逗号分隔的值列表cmd
。是否可以运行这样的查询?
a,b,c
答案 0 :(得分:2)
回答我自己的问题(借助此处发表的评论)
<!---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>