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>
即使 country=us 也总是生成 NOT IN
解决方案
尝试这个test="country == null or country != 'spain' or country != 'UK' "
推荐阅读
- c# - 在 asp.net mvc 5 中发送带有附件 Pdf 问题的电子邮件
- c++ - typedef 模板参数推导失败?
- java - 无法运行 Junit 案例。引发错误“实际上与此模拟的交互为零”
- java - 了解 android MVP 中的漏洞
- python - 使用struct在python3.6中读取结构化二进制数据
- regex - 如何在位置标签中提取 Apache httpd.conf 中的参数值?
- python-2.7 - 张量流 1.11 和 cuda 8
- python - 在二进制文件中查找模式?
- java - OpenCSV Java - CsvToBeanFilter 使用带注释的对象而不是 HeaderColumnNameTranslateMappingStrategy
- php - foreach 循环中的函数在保存到数组时复制返回值