I was updating some ColdFusion old code and had a brain freeze about how to wrap items from a ValueList() function in single quotes, so that I could use them in a query.

Fortunately I found this article from Cold Fusion Jedi. Just use QuotedValueList() instead of ValueList() - each item in the list will be surrounded in single quotes. For example, if ValueList(query.alphabet) returns a,b,c,d, QuotedValueList(query.alphabet) will return 'a','b','c','d'.

If you want to have arbitrary characters (instead of single quotes) around your list items, use ListQualify(). Continuing the example above, ListQualify(ValueList(query.alphabet),":") would return :a:,:b:,:c:,:d:.

I hope this helps somebody!