引用
在工作中遇到mybatis中判断两个集合是否为空,不为空的话遍历;都为空执行 1=0 or 1=0,则查询出来空集合
select login,name,email from users u where
<choose>
<when test="sameEmailList != null and sameEmailList.size > 0 ">
email in <foreach collection="sameEmailList" item="email" open="(" separator="," close=")">
#{email, jdbcType=VARCHAR}
</foreach>
</when>
<otherwise>
1 = 0
</otherwise>
</choose>
<choose>
<when test="sameNameList != null and sameNameList.size > 0">
or name in <foreach collection="sameNameList" item="name" open="(" separator="," close=")">
#{name, jdbcType=VARCHAR}
</foreach>
</when>
<otherwise>
or 1 = 0
</otherwise>
</choose>
ORDER by name, email ASC
https://blog.csdn.net/cloudzpc/article/details/78254479
分享到:
相关推荐
mybatis中文离线文档
mybatis所需的两个关键的dtd文件,没有的话xml文件不能用
mybatis-3.2.2.jar mybatis-spring-1.2.1.jar,与spring融合时使用的两个包
spring boot + spring + mybatis 集合xmlspring boot + spring + mybatis 集合xmlspring boot + spring + mybatis 集合xml
MyBatis 中文注释源码,直接导入eclipse工程即可,源码中加了中文注释,可以学习研究底层,成就自我成长!
MyBatis3官方中文文档高清 MyBatis3官方中文文档高清 MyBatis3官方中文文档高清 MyBatis3官方中文文档高清
mybatis_3.5.9官方中文文档pdf
目录 使用场景 动态标签 if标签 where标签 choose、when、otherwise 标签 ...if标签通常用那个胡where语句,update语句,insert语句中,通过判断参数值来决定是否使用某个查询条件,判断是否更新某一个字段或插入某个字段
mybatis 3 中文 指南
mybatis生成中文注释,
Mybatis API中文帮助文档 Mybatis API中文帮助文档 Mybatis API中文帮助文档 Mybatis API中文帮助文档 Mybatis API中文帮助文档 Mybatis API中文帮助文档 Mybatis API中文帮助文档 Mybatis API中文帮助文档 Mybatis ...
NULL 博文链接:https://bijian1013.iteye.com/blog/2336179
Mybatis 中文手册
本项目是一个spring boot 1.5 和mybatis一个配置实例。下载之后,导入eclipse即可使用.用于学习springboot+mybatis的项目搭建
MyBatis官网中文文档
mybatis中文参考手册 ibatis3中文参考手册
mybatis中,sqlserver分页
mybatis中文文档(详细)
内含:MyBatisCodeHelper-Pro、MybatisX