id IN('1','6','8','10','2')如何按照顺序输出,就是in中的顺序,请高手指点,谢谢,急急
id IN('1','6','8','10','2')如何按照顺序输出,就是in中的顺序,请高手指点,谢谢,急急
查询结果也要按照1,6,8,10,2的顺序
------解决方案--------------------order by charindex(id,'1','6','8','10','2')
------解决方案--------------------
+1
------解决方案--------------------
select *
from [表名]
where id in('1','6','8','10','2')
order by charindex(','+id+',',',1,6,8,10,2,',1)
------解决方案--------------------
id字段上需建索引.
------解决方案--------------------1.先把结果存到临时表
2.order by charindex(','+id+',',',1,6,8,10,2,',1)
------解决方案--------------------可以建立聚族索引