91名师指路-头部
91名师指路

mybatis xml中for循环字符串

由于某些原因,现在不支持支付宝支付,如需要购买源码请加博主微信进行购买,微信号:13248254750

第一种方式:假设我们后台传到xml中的是一个字符串,字段为 increaseStatus ,值为 WT,WS。我们在xml中将其进行循环:

<if test='increaseStatus != null and increaseStatus !=""'>
and increase_status in (
<foreach collection="increaseStatus.split(',')" item="item" index="index" separator=",">
#{item}
</foreach>
)
</if>

第二种方式:

<if test='increaseStatus != null and increaseStatus !=""'>
and FIND_IN_SET(#{increaseStatus,jdbcType=VARCHAR}, increase_status)
</if>


总结:第二种方式比第一种方式效率高很多。


2019-08-12 10:55:34     阅读(2823)

名师出品,必属精品    https://www.91mszl.com

联系博主    
用户登录遮罩层
x

账号登录

91名师指路-底部