使用 MyBatis 的判断,要根据 locate 的值执行不同的判断,但是这两个语句都没有执行到:
<select id="getCountByLocate" resultType="">
select * from tableName
<where>
<if test="locate == '1'">
and b.PROVINCE_VALUE != '2'
</if>
<if test="locate == '2'">
and b.PROVINCE_VALUE = '2'
</if>
</where>
</select>
后来的解决办法是:将 test 条件的 单引号 和 双引号调换一下位置即可:
<if test='locate == "1"'>
and b.PROVINCE_VALUE != '2'
</if>
<if test='locate == "2"'>
and b.PROVINCE_VALUE = '2'
</if>
不太明白这个问题。