首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

select in 排序有关问题

2012-05-11 
select in 排序问题select * from table where id in(10,6,9,20)这样的话 出来的数据是 根据id升序排的请

select in 排序问题
select * from table where id in(10,6,9,20)
这样的话 出来的数据是 根据id升序排的

请教下 怎么根据 in() 里的顺序的倒序来排

就是
20
9
6
10
这样排


作用就是 记录文章的浏览历史


后台
asp
access数据库




[解决办法]

SQL code
select * from table where id in(10,6,9,20)order by charindex(',' + cast(id as nvarchar(20)) + ',' ,',10,6,9,20,') desc
[解决办法]
access里用instr函数,
SQL code
select * from table where id in(10,6,9,20)order by Instr("10,6,9,20",","+cstr(id)) desc 

热点排行
Bad Request.