<select id="checkName" resultType="int" parameterType="String" useCache="true" flushCache="false" timeout="10000">
select count(DISTINCT id) as count from <include refid="table"/> as cd
<where>
<if test="deviceId !=null and deviceId !=''">
cd.deviceId=#{deviceId}
</if>
</where>
select count(DISTINCT id) as count from <include refid="table"/> as cd
<where>
<if test="deviceId !=null and deviceId !=''">
cd.deviceId=#{deviceId}
</if>
</where>
</select>
解决代码如下
<select id="checkName" resultType="int" parameterType="String" useCache="true" flushCache="false" timeout="10000">
select count(DISTINCT id) as count from <include refid="table"/> as cd
<where>
cd.deviceId=#{deviceId}
</where>
</select>