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
<where>
ate.refund_num!=ate.nums
and
ate.create_time between #{startTime} and #{endTime}
<if test="giftType!=null
mybatis中没有if else 用choose when
最新推荐文章于 2024-11-22 07:45:00 发布
本文介绍了在MyBatis中,由于没有直接的else语句,如何利用choose和when结构来实现类似if-else的逻辑控制,以实现更加灵活和清晰的SQL映射。

最低0.47元/天 解锁文章
3685

被折叠的 条评论
为什么被折叠?



