mybatis 的 if 标签 在遇到 传入值 为 0 时,会按 空处理,导致 你在根据状态查询时,sql 语句 不会有 状态 为 0 的查询条件;需要手动的更改 判断;
or 字段名 == 0
select * from tableName
where status != 1
<if test="type != null and type != '' or type == 0">
and type = #{type}
</if>
mybatis 的 if 标签 在遇到 传入值 为 0 时,会按 空处理,导致 你在根据状态查询时,sql 语句 不会有 状态 为 0 的查询条件;需要手动的更改 判断;
or 字段名 == 0
select * from tableName
where status != 1
<if test="type != null and type != '' or type == 0">
and type = #{type}
</if>
相关文章: