<!--查找某用户绑定的药物不良反应报告列表-->
<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 中传入多个不同的参数问题的更多相关文章

  1. php中foreach中使用&的办法

    刚开始在使用foreach时候一直不理解为什么要使用& 后来发现在给一个数组里面添加数据时候很好用 <?phpheader("Content-Type:text/html;ch ...

  2. mybatis中foreach的用法(转)

    foreach一共有三种类型,分别为List,[](array),Map三种. foreach属性 属性 描述 item 循环体中的具体对象.支持属性的点路径访问,如item.age,item.inf ...

  3. 谈一下思考,关于mybatis中<foreach collection="list">中list得来的原因 没看到官方说明

    <foreach> 是在sql语句中进行多个id查询 时用到的,因为mybatis代替jdbc和hibernate, 使用 在xml文件中编写sql语句,这是一个标签文件.然后在 dao层 ...

  4. mybatis 中 foreach 的性能问题及调优

    1.mybatis中最初的sql语句 SELECT 参数1, 参数2, 参数3 FROM 表 WHERE 条件参数1 in <foreach item="item" inde ...

  5. foreach中的collection

    foreach中collection的三种用法 https://www.cnblogs.com/xiemingjun/p/9800999.html foreach的主要用在构建in条件中,它可以在SQ ...

  6. mybatis中foreach使用方法

    作者:学无先后 达者为先 作者:偶尔记一下 foreach一共有三种类型,分别为List,[](array),Map三种. 下面表格是我总结的各个属性的用途和注意点. foreach属性 属性 描述 ...

  7. SQL Server 存储过程中处理多个查询条件的几种常见写法分析,我们该用那种写法

    本文出处: http://www.cnblogs.com/wy123/p/5958047.html 最近发现还有不少做开发的小伙伴,在写存储过程的时候,在参考已有的不同的写法时,往往很迷茫,不知道各种 ...

  8. SQL Server存储过程中使用表值作为输入参数示例

    这篇文章主要介绍了SQL Server存储过程中使用表值作为输入参数示例,使用表值参数,可以不必创建临时表或许多参数,即可向 Transact-SQL 语句或例程(如存储过程或函数)发送多行数据,这样 ...

  9. SQL Server 2008中新增的 1.变更数据捕获(CDC) 和 2.更改跟踪

    概述 1.变更数据捕获(CDC)        每一次的数据操作都会记录下来 2.更改跟踪       只会记录最新一条记录   以上两种的区别:         http://blog.csdn.n ...

随机推荐

  1. 区块链V1版本实现之一

    1. 程序地址:https://gitee.com/Jame_sz/beijing_go_term2.git 2. 程序编写流程: //1. 定义结构(区块头的字段比正常的少) //>1. 前区 ...

  2. CentOS下Mysql简易操作

    Mysql mysql的root密码重置 编辑mysql主配置文件 vim /etc/my.cnf 添加..grant参数 [mysqld] skip-grant 重启mysql服务 service ...

  3. Jdk源码-集合类主要原理和解析

    写在前面 熟悉Jdk原理的重要性不言而喻,作为Java开发者或者面试者,了解其实现原理也显得更为装逼,在Java读书计划我写到了,它是面试中最基础的一部分,所以单独拿出来做个总结,为了更好滴理解和学习 ...

  4. 第15.26节 PyQt(Python+Qt)入门学习:Model/View架构中的便利类QListWidget详解

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一.概述 列表部件(List Widget)对应类QListWidget,是从QListView派生 ...

  5. 凌乱的与ctf无关的小知识点

    (1)在网页中一般不要用记住密码.否则想要知道你的密码很简单. 例子:看样子很安全,别人无法通过这些来获得你的其他密码(尤其是想我这样密码强度不高的人),但是知道要修改前端的选项,你的密码就会被暴露. ...

  6. 快速排序(c++,递归)quick_sort

    放上c++代码,模板 1 #include <iostream> 2 #include<bits/stdc++.h> 3 using namespace std; 4 5 in ...

  7. 笨方法学python笔记

    编程是什么 编程就是通过输出一种语言给计算机"听",命令其去执行相应的操作. 我们称我们给计算机下达的命令称为指令.一般说程序就是有多个指令构成的. 计算机需要使用非常多的电路来实 ...

  8. tensorflow学习笔记——DenseNet

    完整代码及其数据,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/DeepLearningNote 这里结合网络的资料和De ...

  9. 基于Python3.7 Robot Framework自动化框架搭建

    一.Robot Framework 和 Selenium 的区别(面试常问) 主流自动化测试框架有Robot Framework 和 Selenium,请根据实际场景选用不同的框架,以下总结各自优缺点 ...

  10. Nacos源码深度解析1-服务注册初始化(客户端)

    一.初始化 NamingService naming = NamingFactory.createNamingService(properties); 二.通过反射传入properties生成Naco ...