RT...
现在得到的记录是按照1,2,3,5排序的

解决方案 »

  1.   

    select * from `table` 
    where `id` in (3,2,1,5)
    order by INSTR(',3,2,1,5,',concat(',',`id`,','))最近问这个问题的怎么这么多,这是本人在CSDN首创的一种方法。
        [align=center]====  ====
    [/align]
      

  2.   

    其实直接这样:order by field (id,3,2,1,5); 对新手来说更容易理解,嘎嘎
      

  3.   

    select * from `table` where `id` in (3,2,1,5)===》
    这样就不用ORDER BY ,而且还很好的用到了索引。select * from `table` where `id` =3
    union all
    select * from `table` where `id` =2
    union all
    select * from `table` where `id` =1
    union all
    select * from `table` where `id` =5
      

  4.   

    最简单的.不过没有我LS写的效率高.
    select * from `table` where find_in_set(`id`,'3,2,1,5') order by find_in_set(`id`,'3,2,1,5') 
      

  5.   

    select * from `table` where id in (3,2,1,5) order by 
    if(id=3,1,if(id=2,2,if(id=1,3,4)))
    不推荐在ORDER BY 中用字符串函数,因为速度慢