Mybatis choose when用法实例代码 程序员文章站 2023-12-17 09:21:34 mybatis choose when的用法实现代码如下所示: mapper.xml: 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> 以上所述是小编给大家介绍的mybatis choose when用法实例代码,希望对大家有所帮助 上一篇: 下一篇: 推荐阅读 Mybatis choose when用法实例代码 IDEA Maven Mybatis generator 自动生成代码(实例讲解) C#集合类用法实例代码详解 Spring boot + mybatis + orcale实现步骤实例代码讲解 MyBatis动态SQL标签用法实例详解 mybatis实现一对一关联映射实例代码 mybatis动态插入list传入List参数的实例代码 Mybatis choose when用法实例代码 Spring+MyBatis实现数据读写分离的实例代码 Mybatis环境搭建和使用实例代码