Mybatis choose when用法实例代码 程序员文章站 2023-12-10 17:49:22 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用法实例代码,希望对大家有所帮助 上一篇: 索尼PS4/PS Vita游戏机正式入华 PS4售2899元 下一篇: 推荐阅读 Mybatis choose when用法实例代码 Spring+MyBatis实现数据读写分离的实例代码 Mybatis环境搭建和使用实例代码 Spring Boot整合mybatis(一)实例代码 JSP forward用法分析实例代码分析 Spring Boot集成Mybatis的实例代码(简洁版) springmvc+mybatis 做分页sql 语句实例代码 mybatis动态插入list传入List参数的实例代码 vue.js中toast用法及使用toast弹框的实例代码 Mybatis逆向生成使用扩展类的实例代码详解