java动态mybatis xml查询
需要以下动态查询的帮助:
if country==null OR country != (spain || Peru)
select * from emp where country NOT IN (spain,Peru)
else
select * from emp where country=#{country}
我试过这样的方法,但没用:
<when test="country ==null" or country !='spain' or country != 'Peru'">
AND country NOT IN ('spain','peru')
</when>
<otherwise>
AND country=#{country}
</otherwise>
即使国家=美国,也始终不产生
# 1 楼答案
使用双引号来表示字符串
# 2 楼答案
错误的条件,预期的,而不是或
# 3 楼答案
试试这个
test="country == null or country != 'spain' or country != 'UK' "