当使用mybatis 进行like 查询时一定要使用 双引号
#这个是使用了distinct 关键字 来进行不同筛选总数
<select id="selectCountBybi" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT identifier) FROM admin_problem
<where>
<if test="vo.question != '' and vo.question != null">
and `name` like "%"#{vo.question}"%"
</if>
<if test="vo.companyId != '' and vo.companyId != null">
and company_id=#{vo.companyId}
</if>
<if test="1==1">
and is_title='1'
</if>
</where>
</select>
==================================================================
下面是使用distinct 进行去重,因为这个关键字已经进行了排序,所以不需要再次排序,否则会报错
<select id="selectByPag" resultMap="BaseResultMap">
SELECT DISTINCT identifier FROM admin_problem
<where>
<if test="vo.question != '' and vo.question != null">
and `name` like "%"#{vo.question}"%"
</if>
<if test="vo.companyId != '' and vo.companyId != null">
and company_id=#{vo.companyId}
</if>
<if test="1==1">
and is_title='1'
</if>
</where>
limit #{pageNo2},#{vo.pageSize}
</select>