How to convert Query column to a list in ColdFusion

erikvold picture erikvold · Mar 30, 2011 · Viewed 41.8k times · Source

I'm trying to convert ColdFusion query column to a list, what is the best way to do so?

I thought that there is a built in function that allows one to easily convert a query's column in to a list, if there is what is it?

Answer

ale picture ale · Nov 23, 2011

There is a built-in function to do that: ValueList

<cfset myList = ValueList(query.columnname)>

As with all of the list functions, there's an optional delimiter attribute.

<cfset myList = ValueList(query.columnname,"|")>

If you need the values in the list to have double-quotes around them, use QuotedValueList.

<cfset myList = QuotedValueList(query.columnname)>