日期:2014-05-18 浏览次数:20526 次
select * from table where id in(13557,610,3067,215,9139,1313,5705,2156,2486,5913) order by charindex(rtrim(ID),'13557,610,3067,215,9139,1313,5705,2156,2486,5913')
------解决方案--------------------
select * from table where id in(13557,610,3067,215,9139,1313,5705,2156,2486,5913) order by charindex(','+rtrim(ID)+',',',13557,610,3067,215,9139,1313,5705,2156,2486,5913,')
------解决方案--------------------
或用patindex,要通用需要加上','有条件类似用符号分隔(1,11,111)
这类
select * from table where id in(13557,610,3067,215,9139,1313,5705,2156,2486,5913) order by patindex('%,'+rtrim(ID)+',%',',13557,610,3067,215,9139,1313,5705,2156,2486,5913,')