当前位置: 代码迷 >> SQL >> 头疼的SQL排序有关问题
  详细解决方案

头疼的SQL排序有关问题

热度:109   发布时间:2016-05-05 15:26:54.0
头疼的SQL排序问题
select   *   from   AAA   where   ID   in   (2,5,3)
我希望出来结果的顺序跟in里面的顺序一样,   不知道有没有办法实现?

------解决方案--------------------
select * from
(select 1 as ranknum, * from AAA where ID in (2) 
union 
select 2 as ranknum,* from AAA where ID in (5) 
union
select 3 as ranknum,* from AAA where ID in (3) )a
order by ranknum
  相关解决方案