日期:2014-05-17  浏览次数:20909 次

如何保持where in查询后的顺序
参数数组a
int[] a =[2848,2846,2845,2844,2847,2818];

select Id from StateInfo where Id in(2848,2846,2845,2844,2847,2818) ;

结果按从小到大排列了: 2818,2844,2845,2846,2847,2848;
如何保持查询结果仍按参数a里的次序呢?

------解决方案--------------------
select Id from StateInfo where Id in(2848,2846,2845,2844,2847,2818) order by instr('2848,2846,2845,2844,2847,2818',id)