zoukankan      html  css  js  c++  java
  • ROWNUM使用大于查不到值的问题(查询大于10小于21 范围内的数据)

    转  https://blog.csdn.net/jquerys/article/details/52432770

    第一种:

    select t.*, rownum as rid from (
          select  *   from interface_log a,interface_key b,interface c  where  a.inte_log_key=b.intekey_key and   a.inte_log_mainuuid=c.inte_uuid ORDER BY inte_log_cdate desc

      ) t 
    where rownum >10 and rownum <21

    第二种:

    select * from(
            select t.*, rownum as rid from (
                   select  *  from sjzx_interface_log a,sjzx_interface_key b,sjzx_interface c  where  a.inte_log_key=b.intekey_key and  a.inte_log_mainuuid=c.inte_uuid ORDER BY inte_log_cdate desc

            ) t      

            where rownum <21 )
    where rid >10

    第一种会导致错误,

        因为rownum总是从1开始的,第一条不满足去掉的话,第二条的rownum 又成了1。依此类推,所以永远没有满足条件的记录。

        可以这样理解:rownum是一个序列,是Oracle数据库从数据文件或缓冲区中读取数据的顺序。

    第二种先把前21条数据取出来,编号,再从编号中取出第10条之后的

  • 相关阅读:
    表字段出现oracle sql语句关键字时
    使用decode函数
    PL/SQL DEVELOPER 使用小技巧
    Linux静态IP设置修改配置文件
    在idea上使用maven搭建ssm,数据库为mysql
    作业
    SQL 简单的生成xml
    使用CppUnit
    tinyXml的使用
    NSIS 使用技巧
  • 原文地址:https://www.cnblogs.com/hqsbrx/p/9543832.html
Copyright © 2011-2022 走看看