zoukankan      html  css  js  c++  java
  • oracle 分页查询

    使用:
          --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



  • 相关阅读:
    Mac php使用gd库出错 Call to undefined function imagettftext()
    centos 使用 locate
    Mac HomeBrew 安装 mysql
    zsh 命令提示符 PROMPT
    新的开始
    Java 面试题分析
    Java NIO Show All Files
    正确使用 Volatile 变量
    面试题整理 2017
    有10阶梯, 每次走1,2 or 3 阶,有多少种方式???
  • 原文地址:https://www.cnblogs.com/zouhong/p/13646201.html
Copyright © 2011-2022 走看看