Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 动态mybatis xml查询_Java_Mybatis_Spring Mybatis - Fatal编程技术网

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'">