select tab1.*,1 R from tab1 where filed1 = '1'
union
select tab1.*,2 from tab1 where filed1 = '3'
union
select tab1.*,3 from tab1 where filed1 = '2'
order by R
union
select tab1.*,2 from tab1 where filed1 = '3'
union
select tab1.*,3 from tab1 where filed1 = '2'
order by R
select * from tab1 where filed1 in ('1', '3', '2') order by filed1 Asc(或者desc)这种情况可以:
filed1 filed2
1 1
2 3
3 2
select * from (select * from tab1 where filed1 in(1,2,3) order by filed1) order by filed2
结果:1
3
2
order by decode(filed1,'1','1','3','2','2','3','4')
from tab1
where filed1 in ('1', '3', '2')
order by instr(','||'1,3,2'||',',','||filed1||',')
'1','3','2'作为参数外部传入,替换一下就可以了
其实就是按照出现的顺序排序