《Mysql入门解析数据库分页的两种方法对比(row_number()over()和top的对比)》要点:
本文介绍了Mysql入门解析数据库分页的两种方法对比(row_number()over()和top的对比),希望对您有用。如果有疑问,可以联系我们。
一页3条数据 取第一页的数据
select * from (select *,ROW_NUMBER()over(order by id asc) as number from T_News ) as tb1
where number between 1 and 3;
第五页的数据
select * from (select *,ROW_NUMBER()over(order by id asc) as number from T_News ) as tb1
where number between 3*4+1 and 3*5;
自己设定每页几条数据和看第几页
create proc usp_fenye @geshu int,@yeshu int
as
begin
select * from (select *,ROW_NUMBER()over(order by id asc) as number from T_News ) as tb1
where number between @geshu*(@yeshu-1)+1 and @geshu*@yeshu;
end
转载请注明本页网址:
http://www.vephp.com/jiaocheng/6370.html