[thelist] Reordering result set (PHP/MySQL)

Robert Douglas robert.douglas at rightmove.co.uk
Mon Feb 4 03:30:29 CST 2008

Hey all,

I'm getting details from a MySQL db from a set of ids but want the
results ordered the same way as my original query. For example: "select
* from tracks where id in (3,7,2,1);"

This returns a resultset in numeric order (1,2,3,7) but I want them in
the original order. Should I be trying to do this in SQL? Or reordering
the resultset in PHP?

The SQL side, I have no idea about. If PHP is the best/only way, it
feels a little cumbersome (and slow?). Any recommendations on approach?

Any and all suggestions welcome.


This email has been scanned for all viruses by the MessageLabs service. 

More information about the thelist mailing list