<?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. UVA.839 Not so Mobile ( 二叉树 DFS)

    UVA.839 Not so Mobile ( 二叉树 DFS) 题意分析 给出一份天平,判断天平是否平衡. 一开始使用的是保存每个节点,节点存储着两边的质量和距离,但是一直是Runtime erro ...

  2. Mac添加锁屏快捷键

    Mac要想添加锁屏快捷键,必须使用Automator. 1. 打开Automator,创建一个新的服务. 2. 在左侧栏中找到 启动屏幕保护 ,将其拖曳到右侧窗口内,并且修改 服务收到改为" ...

  3. 【神仙题】【P4885】 灭顶之灾

    传送门 Description 请将题目名称的首字母连起来读 Scarlet有一张$n*m$的神秘表格.现在Scarlet向表格中填数字,她会从第一行中的某个格子起,按照从左往右,从上往下的顺序依次填 ...

  4. MySQL、Oracle、DB2等数据库常规排序、自定义排序和按中文拼音字母排序

    MySQL常规排序.自定义排序和按中文拼音字母排序,在实际的SQL编写时,我们有时候需要对条件集合进行排序. 下面给出3中比较常用的排序方式,mark一下 1.常规排序ASC DESC ASC 正序 ...

  5. 关于Mybatis的@Param注解 及 mybatis Mapper中各种传递参数的方法

    原文:https://blog.csdn.net/mrqiang9001/article/details/79520436 关于Mybatis的@Param注解   Mybatis 作为一个轻量级的数 ...

  6. 基于Node.js+MySQL开发的开源微信小程序B2C商城(页面高仿网易严选)

    界面高仿网易严选商城(主要是2016年wap版) 测试数据采集自网易严选商城 功能和数据库参考ecshop 服务端api基于Node.js+ThinkJS+MySQL 计划添加基于Vue.js的后台管 ...

  7. c++11新特性之atomic

    std::atomic_flag std::atomic_flag是一个原子的布尔类型,可支持两种原子操作: test_and_set, 如果atomic_flag对象被设置,则返回true; 如果a ...

  8. [技巧篇]02.关于MyBatis存取图片到MySQL数据Blob字段

  9. 【转】Pyhton 单行、多行注释符号使用方法及规范

    转自:Pyhton 单行.多行注释符号使用方法及规范 python中的注释有多种,有单行注释,多行注释,批量注释,中文注释也是常用的.python注释也有自己的规范,在文章中会介绍到.注释可以起到一个 ...

  10. CSS知识之 background-position 用法详细介绍

    一.语法 background-position : length || length background-position : position || position 二.取值 length   ...