我现在有一个表,item的表表字段:id  text  有一个array('5','3','1','2','4')id中有值1 2 3 4 5 6 7 8 9 10,正常排序我现在想要select id from item where id in ('5','4','1','2','3')有没有方法使得select出来的id 不是按 1 2 3 4 5排序而是按5 4 1 2 3 也就是array的顺序
服务器端语言php.

解决方案 »

  1.   

    select id from item where id in ('5','4','1','2','3') order by
    instr('5','4','1','2','3',id)
      

  2.   

    select id from item where id in ('5','4','1','2','3') order  by locate(concat(',',id,','),',5,4,1,2,3,');
      

  3.   


    select id from item where id in ('5','4','1','2','3') order by find_in_set(id,'5,4,1,2,3')
      

  4.   

    个人意见:建一个临时表存arry();
    然后根据临时表联合查询,在根据他排序。 
    本人菜鸟 只能这样想.等待高手!