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

高级应用select,该怎么解决

2012-01-26 
高级应用selectselect时,条件这么写idin(3,9,10,1),想查询出来的id顺序也是3,9,10,1,而不是1,3,9,10这种,

高级应用select
select时,条件这么写id   in(3,9,10,1),想查询出来的id顺序也是3,9,10,1,而不是1,3,9,10这种,有什么办法吗?

[解决办法]
-- 可以想一个别名,按照制定的顺序硬编码一下,参考:
select [id],alias = case [id]
when 3 then 1
when 9 then 2
when 10 then 3
when 1 then 4
end
from yourTable
order by alias --- 按照别名排序

热点排行