>This puts your sort order in the database, where it belongs.
True. However, if this list is coming from a select box, or similar
element, it may be overkill to insert these into the database and then
select them again.
There is no point in inserting into a table when you can loop over the
list and dynamically create the sorted query.
....snip...
<cfset listLength = listLen(myList)>
<cfquery name="q" datasource="#dsn#">
<cfloop from="1" to="#listLength#" index="thisIndex">
SELECT *, #thisIndex# AS sortOrder
FROM table
WHERE id = #listGetAt(myList, thisIndex)#
<cfif thisIndex lt listLength>
UNION
</cfif>
</cfloop>
ORDER BY sortOrder
</cfquery>
....snip...
It really depends on the number of elements in this list as well as the
number of records in the table and how well the table is indexed.
M!ke
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198056
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54