[thelist] Ordering a recordset by an array

Oren Levin lists at pinetree.net
Tue Oct 14 12:30:18 CDT 2003


I'm not familiar enough with ASP to know if this will work but you might
try:

Select *, 
       decode(id, 15, 1, 7, 2, 10, 3, 4) as sort_order
>From my_table
Where id in (15, 7, 10)
Order by sort_order

Oren

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Ben Gustafson
Sent: Tuesday, October 14, 2003 12:04 PM
To: 'thelist at lists.evolt.org'
Subject: [thelist] Ordering a recordset by an array


Hello All,

I'm trying to figure out how to order a recordset according to the order of
elements in an array. For example, say I have three numbers in the following
order: 15,7,10. What I want to do is something like:

    select * from my_table where id in (15,7,10)

and put the records in the order of the three numbers, so that the record
with an id of 15 is first, and the one with an ID of 7 is second, etc. The
numbers will be pulled from a text file using the FileSystemObject in ASP
Classic. I am using JavaScript as my server-side scripting language.

Any ideas?

Thanks,

--Ben
-- 
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 



More information about the thelist mailing list