这条sql语句可以这样排序吗 ?

[复制链接]
查看11 | 回复2 | 2009-7-11 23:35:36 | 显示全部楼层 |阅读模式
Select * from [guestbook] where guest_id in(5,10,2,3) order by (case when id=5 then 0 case when id=10 then 1case when id=2 then 2case when id=3 then 3 end)或Select * from [guestbook] where guest_id =5 union allSelect * from [guestbook] where guest_id=10Select * from [guestbook] where guest_id=2Select * from ...
回复

使用道具 举报

千问 | 2009-7-11 23:35:36 | 显示全部楼层
--MS SQL用charindex/patindexSelect * from [guestbook] where guest_id in(5,10,2,3) order by patindex('%,'+rtrim(guest_id) +',%',','+@s+',' ) ascMS SQL 通常是这样用:declare @s nva...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行