Home > Database > Mysql Tutorial > 分页查询(用row_number()和开窗函数over()更方便)

分页查询(用row_number()和开窗函数over()更方便)

WBOY
Release: 2016-06-07 14:53:38
Original
1848 people have browsed it

分页查询(用row_number()和开窗函数over()更方便) 查询MyStudents表中第8页中的数据(每页3条记录) www.2cto.com --(1) select * from ( select *, ROW_NUMBER()over(order by FId asc) as Rnumber from MyStudents ) as Tbl3 where Rnumber between (3*7


分页查询(用row_number()和开窗函数over()更方便)

 

查询MyStudents表中第8页中的数据(每页3条记录)

 www.2cto.com  

--(1)

select * from

(

select *,

ROW_NUMBER()over(order by FId asc) as Rnumber

from MyStudents

)

as Tbl3

where Rnumber between (3*7+1) and 3*8

 

--(2)

select top 3 * from MyStudents

where FId not in

(select top (3*7) FId from MyStudents 

order by FId )

order by FId
 

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