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;