mysql,oracle的分頁查詢

mysql,oracle的分頁查詢

mysql:

select empno,ename from students limit 0,10;  1-10條記錄
select empno,ename from students limit 10,10; 11-20條記錄
select empno,ename from students limit 20,10; 21-30條記錄

帶條件的分頁查詢

select empno,ename from students where age=16 limit 20,10;


oracle:

select A.id,A.name,A.age
from (select rownum B,student.* from student where rownum<7)A
where B>3;

子查詢中,rownum必須取別名且不能和列名(字段名)相同,where後面必須用rownum的別名,整個子查詢用A表示。

帶條件的分頁查詢

oracle:
select A.id,A.name,A.age
from (select rownum B,student.* from student where age=16 and rownum<7 )A
where B>3;





發佈了45 篇原創文章 · 獲贊 8 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章