《Mysql入門解析數(shù)據(jù)庫(kù)分頁(yè)的兩種方法對(duì)比(row_number()over()和top的對(duì)比)》要點(diǎn):
本文介紹了Mysql入門解析數(shù)據(jù)庫(kù)分頁(yè)的兩種方法對(duì)比(row_number()over()和top的對(duì)比),希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
?????????????????????? 一頁(yè)3條數(shù)據(jù) 取第一頁(yè)的數(shù)據(jù)
?? select * from (select *,ROW_NUMBER()over(order by id asc) as number from T_News ) as tb1
???? where number between 1 and 3;
第五頁(yè)的數(shù)據(jù)
?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;
?????????????????????? 自己設(shè)定每頁(yè)幾條數(shù)據(jù)和看第幾頁(yè)
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
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/6370.html