sql 中 foreach 中传入多个不同的参数问题
<!--查找某用户绑定的药物不良反应报告列表-->
<select id="selectSurveyListByUserProId" resultType="java.util.HashMap">
SELECT id AS `id`,time AS `time`,
usr_no AS `id_card_num`,
creat_usr_no AS `creat_usr_no`
FROM xy_survey
<where>
<foreach collection="list" index="index" item="userProIdmap" open="(" separator="," close=")">
<if test="userProIdmap != null">
<if test="userProIdmap.SerialNum != null and userProIdmap.SerialNum != ''"><!-- 注意and不能大写 -->
SerialNum = #{userProIdmap.SerialNum}
</if>
<if test="userProIdmap.company_id != null and userProIdmap.company_id != ''">
and company_id = #{userProIdmap.company_id}
</if>
<if test="userProIdmap.usr_no != null and userProIdmap.usr_no != ''">
and creat_usr_no = #{userProIdmap.usr_no}
</if>
</if>
</foreach>
</where>
GROUP BY id, time, usr_no, creat_usr_no
UNION
SELECT id AS `id`,
time AS `time`,
id_card_num AS `id_card_num`,
creat_usr_no AS `creat_usr_no`
FROM xy_survey_temp
<where>
<foreach collection="list" index="index" item="userProIdmap" open="(" separator="," close=")">
<if test="userProIdmap != null">
<if test="userProIdmap.SerialNum != null and userProIdmap.SerialNum != ''"><!-- 注意and不能大写 -->
SerialNum = #{userProIdmap.SerialNum}
</if>
<if test="userProIdmap.company_id != null and userProIdmap.company_id != ''">
and company_id = #{userProIdmap.company_id}
</if>
<if test="userProIdmap.usr_no != null and userProIdmap.usr_no != ''">
and creat_usr_no = #{userProIdmap.usr_no}
</if>
</if>
</foreach>
</where>
GROUP BY id, time, id_card_num, creat_usr_no
ORDER BY `time` DESC
</select>
<!-- 查询临时表获取主用户上传报告的患者数量,根据身份证号去除重复,参数 产品编号,公司id -->
<select id="findCountPersonNumXySurveyTemp" resultType="java.util.Map">
select id_card_num,SerialNum,company_id from xy_survey_temp where SerialNum in
<foreach collection="list" index="index" item="temps" open="(" separator="," close=")">
<if test="temps != null">
<if test="temps.SerialNum != null and temps.SerialNum !=''">
#{temps.SerialNum}
</if>
</if>
</foreach>
and company_id in
<foreach collection="list" index="index" item="temps" open="(" separator="," close=")">
<if test="temps != null">
<if test="temps.company_id != null and temps.company_id !=''">
#{temps.company_id}
</if>
</if>
</foreach>
group by id_card_num,SerialNum,company_id
</select>
sql 中 foreach 中传入多个不同的参数问题的更多相关文章
- php中foreach中使用&的办法
刚开始在使用foreach时候一直不理解为什么要使用& 后来发现在给一个数组里面添加数据时候很好用 <?phpheader("Content-Type:text/html;ch ...
- mybatis中foreach的用法(转)
foreach一共有三种类型,分别为List,[](array),Map三种. foreach属性 属性 描述 item 循环体中的具体对象.支持属性的点路径访问,如item.age,item.inf ...
- 谈一下思考,关于mybatis中<foreach collection="list">中list得来的原因 没看到官方说明
<foreach> 是在sql语句中进行多个id查询 时用到的,因为mybatis代替jdbc和hibernate, 使用 在xml文件中编写sql语句,这是一个标签文件.然后在 dao层 ...
- mybatis 中 foreach 的性能问题及调优
1.mybatis中最初的sql语句 SELECT 参数1, 参数2, 参数3 FROM 表 WHERE 条件参数1 in <foreach item="item" inde ...
- foreach中的collection
foreach中collection的三种用法 https://www.cnblogs.com/xiemingjun/p/9800999.html foreach的主要用在构建in条件中,它可以在SQ ...
- mybatis中foreach使用方法
作者:学无先后 达者为先 作者:偶尔记一下 foreach一共有三种类型,分别为List,[](array),Map三种. 下面表格是我总结的各个属性的用途和注意点. foreach属性 属性 描述 ...
- SQL Server 存储过程中处理多个查询条件的几种常见写法分析,我们该用那种写法
本文出处: http://www.cnblogs.com/wy123/p/5958047.html 最近发现还有不少做开发的小伙伴,在写存储过程的时候,在参考已有的不同的写法时,往往很迷茫,不知道各种 ...
- SQL Server存储过程中使用表值作为输入参数示例
这篇文章主要介绍了SQL Server存储过程中使用表值作为输入参数示例,使用表值参数,可以不必创建临时表或许多参数,即可向 Transact-SQL 语句或例程(如存储过程或函数)发送多行数据,这样 ...
- SQL Server 2008中新增的 1.变更数据捕获(CDC) 和 2.更改跟踪
概述 1.变更数据捕获(CDC) 每一次的数据操作都会记录下来 2.更改跟踪 只会记录最新一条记录 以上两种的区别: http://blog.csdn.n ...
随机推荐
- 基于openeuler aarch_64 下,从源码的角度搭建Tensorflow
为什么从源码编译Tensorflow? 安装过的人们都知道如果 pip install tensorflow 的话会报错Your CPU supports instructions that this ...
- Kafak探究之路- 内部结构小结
1.框架与工作流 2 内部结构 kafka的每个主题分区的数据在 first-0(主题名-分区号)文件夹下,保存 n组xxx.log文件与xxx.index文件.log文件存发送消息的元数据,每个大小 ...
- 老猿学5G扫盲贴:与用户和终端相关的名词UE、SUPI、GPSI、PEI
专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt+moviepy音视频剪辑实战 专栏:PyQt入门学习 老猿Python博文目录 老猿学5G博文目录 和4 ...
- PyQt(Python+Qt)学习随笔:QAbstractItemView的defaultDropAction属性
老猿Python博文目录 老猿Python博客地址# 一.概述 defaultDropAction属性用于控制QAbstractItemView及其子类的实例视图中拖放时放下的默认操作.该属性的类型为 ...
- 常见SQL注入点判断
sql注入手工检测 SQL注入手工检测 1基本检测 数字型 字符型 搜索型 POST注入 布尔盲注 报错注入 堆叠注入 判断是什么数据库 2绕过技巧 大小写 替换关键字 使用编码 注释和符号 等价函数 ...
- 0、tensorflow学习开始
结合tensorflowtf 2.x , tensorflow 1.x, pytorch来深入理解深度学习架构,用博客来记录这一系列,日后也方便回顾,博客中也会加入个人理解和感悟 参考的博客列表如下: ...
- Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.
用pycharm连接mysql报错 改变serverTimezone 改了之后确实可以连接上mysql数据库
- LZZ磁力资源搜索4.2.2,整合多个站点,大部分资源都能搜到
资源搜索 4.2.2.20200310网友提出的功能已完成1:新增 时间日期排序,单击表头或右键菜单选择,即可自动排序2:新增 搜索完毕 音效开启或关闭 选项3:资源站点 Sunyaa 由聚合站点改为 ...
- ThreadLocal原理记录,别被坑了!!
简介 ThreadLocal的用处 ThreadLocal是为了将数据记录一份到某个线程里,确保该数据线程安全 例如数据库的Connection放入ThreadLocal,一个事务会用到很多DAO,但 ...
- 题解-NOI2016 优秀的拆分
NOI2016 优秀的拆分 \(T\) 组测试数据.求字符串 \(s\) 的所有子串拆成 \(AABB\) 形式的方案总和. 数据范围:\(1\le T\le 10\),\(1\le n\le 3\c ...