MyBatis SQL分頁處理及查詢總數據量
阿新 • • 發佈:2018-09-02
batis ger 分頁 var index add and resultmap ted
查詢數據總數:
<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 > <iftest="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分頁處理及查詢總數據量