其他分享
首页 > 其他分享> > Mybatis choose when otherwise 标签

Mybatis choose when otherwise 标签

作者:互联网

<select id="listAgentWithdrawApplyOrder" resultType="org.channel.entity.agent.AgentWithDrawApplyOrderDto">
	select * from t_agent_withdraw_apply_order
	// where 标签会去掉 SQL 前面多余的 and
	<where>
		<if test="withdrawType != null ">
			// 如果 withdrawType == 1 则查询条件为 and F_withdraw_type = 0
			// 如果 withdrawType == 2 则查询条件为 and F_withdraw_type = 5015
			// 如果 withdrawType != 1 || withdrawType != 2 则查询条件为 and F_withdraw_type in(5005,5067,5089)
			<choose>
				<when test="withdrawType == 1">
					and F_withdraw_type = 0
				</when>
				<when test="withdrawType == 2">
					and F_withdraw_type = 5015
				</when>
			</choose>
			<otherwise>
			  and F_withdraw_type in(5005,5067,5089)
			</otherwise>
		</if>
	</where>
</select>

  

标签:5067,5015,when,查询,withdrawType,choose,withdraw,Mybatis,type
来源: https://www.cnblogs.com/xiaomaomao/p/16415365.html