方法一:一般用法
select * from orcl_test t
<where>
<if test="query == 0">
and t.status = 1
</if>
<if test="query != 0">
and t.status NOT IN (2,3,4)
</if>
and t.delete_flag = 1
</where>
方法二:使用choose标签代替if-else。
select * from orcl_test t
<where>
<choose>
<when test="query == 0">
and t.status = 1
</when>
<otherwise>
and t.status IN (2,3,4)
</otherwise>
</choose>
and t.delete_flag = 1
</where>