<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd!= null">
<!-- namespace:必须与对应的接口全类名一致 id:必须与对应接口的某个对应的方法名一致 <!DOCTYPE mapper PUBLIC
"-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -->

<mapper namespace="">
<resultMap type="HrsBabyHealth" id="HrsBabyHealthAll">
<result property="babyId" column="BABY_ID"/>
<result property="babaNo" column="BABA_NO"/>
<result property="userId" column="USER_ID_"/>
<result property="petName" column="PET_NAME"/>
<result property="name" column="NAME"/>
<result property="idCard" column="ID_CARD"/>
<result property="genderId" column="GENDER_ID"/>
<result property="birthday" column="BIRTHDAY"/>
<result property="birthTime" column="BIRTH_TIME"/>
<result property="inputDate" column="INPUT_DATE_"/>
<result property="dataSource" column="DATA_SOURCE"/>
<result property="orgName" column="ORG_NAME"/>
<result property="className" column="CLASS_NAME"/>
<result property="orgNameStr" column="ORG_NAMESTR"/>
<result property="classNameStr" column="CLASS_NAMESTR"/>
<result property="trueAge" column="TRUE_AGE"/>
<result property="delStatue" column="DEL_STATUE"/>
</resultMap>
<select id="findHrsBabyHealthCount" parameterType="HrsBabyHealth" resultType="java.lang.Long">
select count(*)
from HRS_BABY_HEALTH
<where>
<if test = " babaNo != null"> BABA_NO = #{babaNo} </if>
<if test = " userId != null">AND USER_ID_ = #{userId} </if>
<if test = " petName != null">AND PET_NAME = #{petName} </if>
<if test = " name != null">AND NAME = #{name} </if>
<if test = " idCard != null">AND ID_CARD = #{idCard} </if>
<if test = " genderId != null">AND GENDER_ID = #{genderId} </if>
<if test = " birthday != null">AND BIRTHDAY = #{birthday} </if>
<if test = " birthTime != null">AND BIRTH_TIME = #{birthTime} </if>
<if test = " inputDate != null">AND INPUT_DATE_ = #{inputDate} </if>
<if test = " dataSource != null">AND DATA_SOURCE = #{dataSource} </if>
<!-- <if test = " orgName != null">AND ORG_NAME in (${orgName}) </if> -->
<if test = " orgNameList != null">
AND ORG_NAME in
<foreach collection="orgNameList" item="item" index="index" separator="," open="(" close=")">
${item}
</foreach>
</if>
<if test = " className != null">AND CLASS_NAME = #{className} </if>
<if test = " trueAge != null">AND TRUE_AGE = #{trueAge} </if>
<if test = " delStatue != null">AND DEL_STATUE = #{delStatue} </if>
</where>
</select>
<select id="findHrsBabyHealthAllByWhere" parameterType="HrsBabyHealth" resultMap="HrsBabyHealthAll">
select BABY_ID,BABA_NO,USER_ID_,PET_NAME,NAME,ID_CARD,GENDER_ID,BIRTHDAY,BIRTH_TIME,h.INPUT_DATE_,DATA_SOURCE,ORG_NAME,CLASS_NAME,TRUE_AGE,g.GROUP_NAME AS CLASS_NAMESTR,o.NAME_ AS ORG_NAMESTR,h.DEL_STATUE
from HRS_BABY_HEALTH h
LEFT JOIN hrs_group g ON g.GROUP_ID=h.CLASS_NAME
LEFT JOIN organization_ o ON o.ORG_ID_=h.ORG_NAME
<where>
<if test = " babyId != null">AND BABY_ID = #{babyId} </if>
<if test = " babaNo != null">AND BABA_NO = #{babaNo} </if>
<if test = " userId != null">AND h.USER_ID_ = #{userId} </if>
<if test = " petName != null">AND PET_NAME like '%'||#{petName}||'%' </if>
<if test = " name != null">AND h.NAME like '%'||#{name}||'%' </if>
<if test = " idCard != null">AND ID_CARD = #{idCard} </if>
<if test = " genderId != null">AND GENDER_ID = #{genderId} </if>
<if test = " birthday != null">AND h.BIRTHDAY = #{birthday} </if>
<if test = " birthTime != null">AND h.BIRTH_TIME = #{birthTime} </if>
<if test = " inputDate != null">AND h.INPUT_DATE_ = #{inputDate} </if>
<if test = " dataSource != null">AND DATA_SOURCE = #{dataSource} </if>
<if test = " orgNameList != null">
AND h.ORG_NAME in
<foreach item="item" index="index" collection="orgNameList"
separator="," open ="(" close=")" >
${item}
</foreach>
</if>
<if test = " className != null">AND h.CLASS_NAME = #{className} </if>
<if test = " trueAge != null">AND h.TRUE_AGE = #{trueAge} </if>
<if test = " delStatue != null">AND h.DEL_STATUE = #{delStatue} </if>
</where>
ORDER BY BABY_ID desc
<if test = "start != null and limit != null">limit #{start},#{limit}</if>
</select>
</mapper>

关于级联查询,mybatis的更多相关文章

  1. Mybatis 级联查询 (一对多 )

    后台系统中 涉及到添加试卷 问题 答案的一个模块的.我需要通过试卷 查询出所有的试题,以及试题的答案.这个主要要使用到Mybatis的级联查询. 通过试卷 查询出与该试卷相关的试题(一对多),查询出试 ...

  2. Mybatis 之级联查询 一对多配置

    Mybatis级联 查询相对于hibenate是有点麻烦,但是相应好处也是有的,Mybatis轻量.根据自己要的字段配置方便 一对多配置用   <collection property=&quo ...

  3. mybatis级联查询,多对一查询问题

    在使用Mybatis进行多表级联查询时遇到了一个问题:查询结果只有一项,但正确结果是两项.经测试,SQL语句本身没有问题. 在SQL映射文件(XML)中: <!-- 级联查询数据 --> ...

  4. Mybatis中使用级联查询,一对多的查询

    一.需求描述 自己在开发一个小程序的过程中,需要做的一个查询是稍微比较复杂的查询,根据用户信息去查询用户所对应的宠物信息. 一个用户可能对应多个宠物,所以在用户和宠物信息的对应关系就是一对多的关系. ...

  5. JavaSpring中级联查询

    一对一级联查询映射文件PersonMapper.xml代码: <?xml version="1.0" encoding="UTF-8"?> < ...

  6. Oracle级联查询

    在ORACLE 数据库中有一种方法可以实现级联查询   select  *                //要查询的字段 from table              //具有子接点ID与父接点I ...

  7. 三级级联查询省份名称和编码(保证名称不重复)的SQL语句

    三级级联查询省份名称和编码(保证名称不重复)的SQL语句 1.省份.地市和县级数据库表 2.SQL语句 SELECT DISTINCT t.`province_name`,t.`province_co ...

  8. oracle使用connect by进行级联查询 树型菜单

    Oracle使用connect by进行级联查询 树型菜单(转) connect by可以用于级联查询,常用于对具有树状结构的记录查询某一节点的所有子孙节点或所有祖辈节点. 来看一个示例,现假设我们拥 ...

  9. 使用cglib实现数据库框架的级联查询

    写在前面的 这一章是之前写的<手把手教你写一个Java的orm框架> 的追加内容.因为之前写的数据库框架不支持级联查询这个操作,对于有关联关系的表用起来还是比较麻烦,于是就准备把这个功能给 ...

随机推荐

  1. [BZOJ4822] [CQOI2017] 老C的任务

    题目链接 BZOJ:https://lydsy.com/JudgeOnline/problem.php?id=4822. 洛谷:https://www.luogu.org/problemnew/sho ...

  2. BZOJ4870:[SHOI2017]组合数问题——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=4870 https://www.luogu.org/problemnew/show/P3746 看网上 ...

  3. HDU 3507 斜率优化dp

    Print Article Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)To ...

  4. Uva-oj Product 大数乘法

    Product Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Des ...

  5. G. Trace ACM-ICPC 2018 徐州赛区网络预赛 线段树写法

    There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy  ...

  6. Japan POJ - 3067 转化思维 转化为求逆序对

    Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Jap ...

  7. bzoj 1811: [Ioi2005]mea 贪心,乱搞

    [Ioi2005]mea Time Limit: 20 Sec  Memory Limit: 64 MBSubmit: 690  Solved: 257[Submit][Status][Discuss ...

  8. python基础---输入输出

    1.输入字符串. name=input()   or name=input('please input a string') 这样可以接收一个字符串,包括空格,都可以输入.只有回车不接受,作为结束符, ...

  9. UnknownHostException

    1.查看Centos版本号,不同版本修改的方式可能不一样 cat /etc/issue 查看版本 2.通过hostname命令查看当前主机名 hostname 3.编辑network文件修改hostn ...

  10. 【BZOJ2815】【ZJOI2012】灾难 [LCA]

    灾难 Time Limit: 10 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 阿米巴是小强的好朋友.  阿米巴和小强 ...