MYSQL实现如下:
select * from dbf
where id in(10,6,44,63,54,93,106,116,100,148,184,171,196,217,228)   
order by charindex(','+rtrim(id)+ ',',',10,6,44,63,54,93,106,116,100,148,184,171,196,217,228,') 要在ORACEL上面怎么实现同样的功能,按in里的id号顺序查询结果请各大侠指点!谢谢!

解决方案 »

  1.   


    SQL> select * from t1;        ID NAME
    ---------- --------------------
             1 tom
             2 jack
             3 lily
             4 maySQL> select * from t1
      2  where id in (2,3,1)
      3  order by id;        ID NAME
    ---------- --------------------
             1 tom
             2 jack
             3 lilySQL> select * from t1
      2  where id in (2,3,1)
      3  order by decode(id,2,1,3,2,1,3);        ID NAME
    ---------- --------------------
             2 jack
             3 lily
             1 tom
      

  2.   

    charindex 改成 INSTR() 函数就行了。
      

  3.   

    还有个方法,就是UNION ALL 了,每个条件UNION