i.e. it returns array in 1,2,3 instead of 2,3,1.
how do I get Mysql to return results in order given by the IN clause?
Code: Select all
SELECT * FROM detail WHERE ref_number IN (2,3,1)Moderator: General Moderators
Code: Select all
SELECT * FROM detail WHERE ref_number IN (2,3,1)well, in MySQL much simplier way would be to use [mysql_man]field[/mysql_man] function:timvw wrote: in mysql (don't know for standard sql) you can use CASE to build the relation...
Code: Select all
SELECT * FROM detail WHERE ref_number IN (2,3,1) order by field(ref_number, 2, 3, 1) asc