1. 程式人生 > >MyBatis多條件分頁查詢,返回總記錄數

MyBatis多條件分頁查詢,返回總記錄數

 <!-- 通過多條件分頁查詢,返回總記錄數 -->
  <select id="selectPageCount" parameterType="page" resultType="Integer">
  select count(1) from article 
  <where>
    <if test="paramEntity.markdown!=null">and markdown like #{paramEntity.markdown}</if>
    <if test="paramEntity.title!=null">and title like #{paramEntity.title}</if>
    <if test="paramEntity.content!=null">and content like #{paramEntity.content}</if>
    <if test="paramEntity.userId!=null">and a.user_id = #{paramEntity.userId}</if>  
    <if test="paramEntity.articleType!=null">and article_type = #{paramEntity.articleType}</if>          
    </where>
  </select>