一个SQL排序的问题
比如:
select * from table1 where id in (3,6,2,8)
我想让它按条件(3,6,2,8)的顺序来排序,不知道如何实现呢?
[解决办法]
- SQL code
select * from table1 where id in (3,6,2,8) order by charindex(ltrim(id),'3,6,2,8')
发布时间: 2012-01-20 18:53:53 作者: rapoo
一个SQL排序的问题
比如:
select * from table1 where id in (3,6,2,8)
我想让它按条件(3,6,2,8)的顺序来排序,不知道如何实现呢?
[解决办法]
select * from table1 where id in (3,6,2,8) order by charindex(ltrim(id),'3,6,2,8')