Mybatis choose when用法实例代码
时间:2022-04-30 09:21:49|栏目:JAVA代码|点击: 次
mybatis choose when的用法实现代码如下所示:
mapper.xml:
<select id="query" resultType="map" parameterType="map">
select
<choose>
<when test="cityId == '00' ">
a.city_id as CITYID,
</when>
<otherwise>
<choose>
<when test="cityId == '0001' and statsDimension==1">
a.level1_maintain_unit_id as CITYID,
</when>
<otherwise>
a.county_id as CITYID,
</otherwise>
</choose>
</otherwise>
</choose>
sum(ONUNUM) as ONUNUM,
sum(ONTNUM) as ONTNUM
from new_olt_upopt_sp_month_${tableDate} a
where 1 = 1
<if test="cityId == '0001' and statsDimension==1">
and a.city_id = '0001'
</if>
<![CDATA[and a.gather_time >= ${startDate}]]>
<![CDATA[and a.gather_time <= ${endDate}]]>
group by
<choose>
<when test="cityId == '00' ">
a.city_id
</when>
<otherwise>
<choose>
<when test="cityId == '0001' and statsDimension==1">
a.level1_maintain_unit_id
</when>
<otherwise>
a.county_id
having a.county_id in
(select city_id from tab_city
where city_id= #{cityId} or parent_id=#{cityId})
</otherwise>
</choose>
</otherwise>
</choose>
</select>
上一篇:JPA @ManyToMany 报错StackOverflowError的解决
栏 目:JAVA代码
下一篇:Java深入了解数据结构之二叉搜索树增 插 删 创详解
本文标题:Mybatis choose when用法实例代码
本文地址:http://www.codeinn.net/misctech/200576.html


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




