当前位置:   article > 正文

oracle实现分页代码实现_oracle分页查询代码

oracle分页查询代码

1.oracle实现分页sql代码实现

select *
  from (select c.*, rownum n
          from (select b.* from flhgbb_law_book b where b.file_name like '%中华%' order by create_time desc) c)
 where n >  5*(1 - 1) 
   and n <= 1 * 5


--5是每页分几条
--1是当前页数也就是第一页
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
1.这是我的模糊查询条件:

from (select b.* from flhgbb_law_book b where b.file_name like ‘%中华%’ order by create_time desc) c

 List<FlhgbbLawBook> ByPage = flhgbbLawBookService.findOrderByPage(fileName, pageSize * (pageNum - 1), (pageNum * pageSize));
  • 1

数据库sql:

  select *
        from (select c.*, rownum n
        from (select b.* from flhgbb_law_book b
        <include refid="getFileBook"/>
        order by create_time desc) c)l
        where l.n &gt; #{pageSize}
        and l.n &lt;= #{pageNum}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

查询条件:

    <sql id="getFileBook">
        <where>
            <if test="fileName != null and fileName !=''">
                and b.file_name like '%' || #{fileName,jdbcType=VARCHAR} || '%'
            </if>
        </where>
    </sql>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/475369
推荐阅读
相关标签
  

闽ICP备14008679号