码迷,mamicode.com
首页 > 数据库 > 详细

MyBatis SQL分页处理及查询总数据量

时间:2018-09-02 02:11:35      阅读:334      评论:0      收藏:0      [点我收藏+]

标签:end   处理   automatic   分页   tis   resultmap   char   ati   HERE   

查询数据总数:
<select id="selectCount" resultType="java.lang.Integer"> <!-- WARNING - @mbggenerated This element is automatically generated by MyBatis Generator, do not modify. --> select count(id) from tb_user <where > <if test="username != null" > and username like ‘%${username,jdbcType=VARCHAR}%‘ </if> <if test="start_time != null" > and addtime &gt;= #{start_time,jdbcType=TIMESTAMP} </if> <if test="end_time != null" > and addtime &lt;= #{end_time,jdbcType=TIMESTAMP} </if> </where> </select>

分页查询: <select id="getUserForPage" resultMap="BaseResultMap" > <!-- WARNING - @mbggenerated This element is automatically generated by MyBatis Generator, do not modify. --> select <include refid="Base_Column_List" /> from tb_user <where > <if test="username != null" > and username like ‘%${username,jdbcType=VARCHAR}%‘ </if> <if test="start_time != null" > and addtime &gt;= #{start_time,jdbcType=TIMESTAMP} </if> <if test="end_time != null" > and addtime &lt;= #{end_time,jdbcType=TIMESTAMP} </if> </where> limit #{index},#{num} </select>

 

MyBatis SQL分页处理及查询总数据量

标签:end   处理   automatic   分页   tis   resultmap   char   ati   HERE   

原文地址:https://www.cnblogs.com/hjy2018/p/9572045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!