Home  >  Article  >  Database  >  SQL2005 高效分页sql查询语句经典实例

SQL2005 高效分页sql查询语句经典实例

WBOY
WBOYOriginal
2016-06-07 17:47:00982browse

好了看了上面的一多实例你就知道了 SQL2005 高效分页sql查询语句经典实例用法了吧,其实代码都很简单哦。

方法一 SQL2005 高效分页sql查询语句经典实例

代码如下:
select top 10 * from
( select top (@Page * 10) ROW_NUMBER() OVER (order by id) as RowNum, id, username
from Guest where username = 'user'
) as T
where RowNum > ((@Page - 1) * 10)

2
select * from
( select ROW_NUMBER() OVER(order by id) as RowNum,id,username
from Guest where username = 'user'
) as T
where RowNum between 31 and 60

3、

with T as
(select ROW_NUMBER() OVER(order by id) as RowNum,,id,username
from Guest where username = 'user'
)
select * from T
where RowNum between 31 and 60

好了看了上面的一多实例你就知道了 SQL2005 高效分页sql查询语句经典实例用法了吧,其实代码都很简单哦。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn