Java 动态mybatis xml查询
需要以下动态查询的帮助:Java 动态mybatis xml查询,java,mybatis,spring-mybatis,Java,Mybatis,Spring Mybatis,需要以下动态查询的帮助: 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'"
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>
试试这个test=“country==null或country!=“西班牙”或country!=“英国”
使用双引号来字符串
<when test='country == null or !country.equals("spain") or !country.equals("uk")'>
AND country NOT IN ('spain','uk')
</when>
<otherwise>
AND country=#{country}
</otherwise>
国家不在(‘西班牙’、‘英国’)
国家=#{country}
错误条件,应为,而不是或始终生成NOT IN
<when test="country !='spain' and country != 'uk'">