本文主要是介绍mybatis choose when用法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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 ONTNUMfrom new_olt_upopt_sp_month_${tableDate} awhere 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_idhaving 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用法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!