[thelist] tip: CF query in a custom order
nagrom
morgan at morgankelsey.com
Mon May 6 11:45:00 CDT 2002
<tip type="ColdFusion- output a query in a custom order">
lets say you want to run a query, but need to output it in a custom order
not obtainable with ORDER BY.
(you may have a list of keys from a verity search, for instance, and want to
preserve the order)
you can do it like this in ColdFusion:
<cfset list = "9,3,6,1,7,3,2,4,8,5">
<cfquery name="qTest" datasource="ds">
SELECT * FROM tableName
WHERE PrimKey IN (#list#)
</cfquery>
<cfoutput>
<cfloop list="#list#" index="i">
<br />#qTest.PrimKey[i]#
</cfloop>
</cfoutput>
</tip>
More information about the thelist
mailing list