MyBatis SQL分页处理及查询总数据量
Posted 大叔加油
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MyBatis SQL分页处理及查询总数据量相关的知识,希望对你有一定的参考价值。
查询数据总数:
<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 >= #{start_time,jdbcType=TIMESTAMP} </if> <if test="end_time != null" > and addtime <= #{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 >= #{start_time,jdbcType=TIMESTAMP} </if> <if test="end_time != null" > and addtime <= #{end_time,jdbcType=TIMESTAMP} </if> </where> limit #{index},#{num} </select>
以上是关于MyBatis SQL分页处理及查询总数据量的主要内容,如果未能解决你的问题,请参考以下文章