Need help with following dynamic query:
if country==null OR country != (spain || Peru)
select * from emp where country NOT IN (spain,Peru)
else
select * from emp where country=#{country}
I tried something like this but its not helping:
<when test="country ==null" or country !='spain' or country != 'Peru'">
AND country NOT IN ('spain','peru')
</when>
<otherwise>
AND country=#{country}
</otherwise>
Always generate NOT IN even if country=us
<when test="country !='spain' and country != 'uk'">
wrong condition, expected and instead of or