mybatis中的mapper.xml中如何使用in方法

项目场景:mybatis中的mapper.xml中如何使用in方法

提示:mapper.xml中如何使用in方法一般都是like或=

解决方案:见SQL

提示:使用foreach

<if test="List != null and List.size()!=0 ">
	and list in
	<foreach collection="List" item="item" index="index" open="(" close=")" separator=",">
		#{item}
	</foreach>
</if>

注意,传入的参数是List ,如果传入的是array 则需要修改 collection部分定义为 collection=“array”

在MyBatis中使用in关键字参数为集合时,需要使用到foreach标签。
下面详细介绍以下foreach标签的几个参数
mybatis中的mapper.xml中如何使用in方法_第1张图片

你可能感兴趣的:(MySQL,mybatis)