当前位置:Gxlcms > 数据库问题 > oracle的分页查询

oracle的分页查询

时间:2021-07-01 10:21:17 帮助过:13人阅读

使用:
      --rownum关键字:oracle对外提供的自动给查询结果编号的关键字,与每行的数据没有关系。
        --注意:rownum关键字只能做< <=的判断,不能进行> >=的判断
      select rownum ,e.* from emp e;
      --查询员工信息的前5条数据 第一页数据
      select rownum r,e.* from emp e where rownum <=5;
      select * from (select rownum r,e.* from emp e where rownum <=5) t where r>0;
      --查询员工信息的6-10条数据 第二页数据
      select rownum r,e.* from emp e where rownum <=10;
      select rownum,t.* from (select rownum r,e.* from emp e where rownum <=10) t where r>5;
      --查询员工信息的11-15条数据 第三页数据
      select rownum r,e. * from emp e where rownum<=15;
      select * from (select rownum r,e. * from emp e where rownum<=15) t where r>10;
      --分页规律总结:每页显示m条数据,查询第n页数据
      select * from (select rownum r,e. * from 要分页的表 e where rownum<=m*n) t where r>m*n-m ;
             --要分页的表既可以是真实的表,也可以是一个查询语句
      --分页查询员工信息按照工资排序
      select * from (select rownum r,t.* from (select * from emp  order by sal) t where rownum<=10 ) where r>5

     
     
     
     
     
     
     
     
     
     
     
     
 
     
     
     
     

oracle的分页查询

标签:工资   信息   分页   rom   from   员工信息   排序   有关   oracl   

人气教程排行