Home > Database > Mysql Tutorial > body text

SQL 分页

WBOY
Release: 2016-06-07 17:44:55
Original
1049 people have browsed it

分页 select * from ( select *, Row_NUMBER () over ( order by 列名) as num from 表) as t where num between 1 and 5 order by time desc 存储过程 create proc usp_GetPage @pageIndex int , --页码 @pageSize int , --页容量 @pageCo unt int output -

分页

select * from

  (select *, Row_NUMBER() over(order by 列名) as num from 表) as t

where num between 1 and 5

order by time desc

存储过程

create proc usp_GetPage

  @pageIndex int,      --页码

  @pageSize int,       --页容量 

  @pageCount int output        --共多少页

as

  

  select @n=COUNT(*) from 表

  set @pageCount =ceiling(@n*1.0/@pageSize )

select * from 

  (select *, ROW_NUMbER() over(order by 列名)as num from 表) as t

where num between(@pageIndex -1)*@pageCount +1 and @pageIndex *@pageSize 

order by

 

,美国服务器,香港空间,香港服务器租用
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!