进来看下我的sql分页

asdfa23rdadsdfa 2010-12-08 04:06:01

select top(@pagesize) id,ap_iid,ap_name,ap_permissions_help,ap_function_help,ap_date
from #tb where i >
(
select isnull(max(i),0) from
(select top(@pagesize*(@pageno-1)) i from #tb order by i) b
)

上面这sql分页语句没问题。
但是加where条件之后出来的数据就不对了。

这是为什么?

not in的分页方式就可以。但是not in的速度没有上面的分页方式速度快
...全文
38 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
asdfa23rdadsdfa 2010-12-08
  • 打赏
  • 举报
回复
select top(@pagesize) id,ap_iid,ap_name,ap_permissions_help,ap_function_help,ap_date
from #tb where i >
(
select isnull(max(i),0) from
(select top(@pagesize*(@pageno-1)) i from #tb order by i) b
)
比方说
where id between 1 and 100000

order by i 这样吗?

guguda2008 2010-12-08
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 billpu 的回复:]

没有order by
[/Quote]
正解
billpu 2010-12-08
  • 打赏
  • 举报
回复
没有order by

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧