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>
<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>
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: SSM框架——实现分页和搜索分页
- 下一篇: Mysql分页数据显示总数恒为1问题的分析与解决