mybatis中没有if else 用choose when

  • Post author:
  • Post category:其他


SELECT
<choose>
   <when test="statisticsType!=null and statisticsType!='' and statisticsType==1">
      ate.`direct_superior` as userId,
   </when>
   <otherwise>
      ate.team_leader as userId,
   </otherwise>
</choose>
au.username,
au.mobile
<choose>
   <when test="isUpgrade!=null and isUpgrade!='' and isUpgrade==1">
      ,count(ate.nums) as count
   </when>
   <otherwise>
      ,sum(if(ate.is_upgrade=1,ate.nums-1-ate.refund_num,ate.nums-ate.refund_num)) as count
   </otherwise>
</choose>
FROM
au_giftpack_extra ate
LEFT JOIN au_user au ON
<choose>
   <when test="statisticsType!=null and statisticsType!='' and statisticsType==1">
      ate.`direct_superior`
   </when>
   <otherwise>
      ate.team_leader
   </otherwise>
</choose>
= au.id
<



版权声明:本文为yuntaishan0102原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。