我是靠谱客的博主 酷炫冥王星,这篇文章主要介绍mybaitis 的 mapper.xml 文件中 参数为List集合SQL 的写法。mybaitis 的 mapper.xml 文件中 参数为List集合SQL 的写法。,现在分享给大家,希望可以做个参考。
mybaitis 的 mapper.xml 文件中 参数为List集合SQL 的写法。
1、应用场景:
传参:
MaterialCodeList, activity_end_time,userCode
具体SQl:
<if test> 的验证: "MaterialCodeList != null and MaterialCodeList.size()>0"
<foreach > 循环: 循环体:item 序号:index 集合:collection 分割符:separator
<select id="selectPreDiscountInfoByErpCodeAndMaterialCode" resultMap="BaseResultMap">
SELECT ps.MATERIAL_CODE,ps.`NAME`,ps.DISCOUNT_AMOUNT from pre_discount_sku ps where ps.pre_discount_id in(
select pd.id from pre_discount pd where pd.discount_status = '1' and pd.user_code = #{userCode,jdbcType=VARCHAR} and to_days(pd.activity_end_time) >= to_days(now())
)
<if test="MaterialCodeList != null and MaterialCodeList.size()>0">
and ps.material_code in(
<foreach item="item" index="index" collection="MaterialCodeList" separator=",">
#{item}
</foreach>
)
</if>
</select>
最后
以上就是酷炫冥王星最近收集整理的关于mybaitis 的 mapper.xml 文件中 参数为List集合SQL 的写法。mybaitis 的 mapper.xml 文件中 参数为List集合SQL 的写法。的全部内容,更多相关mybaitis内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复