mybatis:查询数组字段的SQL写法

废话不说,直接上代码:

<if test="type != null and type != ''">
	AND a.`type` IN
		<foreach item="typeArray" collection="type.split(',')" open="(" separator="," close=")">
			#{typeArray}
		</foreach>
</if>

注:这种方法是把传入的字符串用逗号分割成数组,然后进行条件查询,非常方便

猜你喜欢

转载自blog.csdn.net/weixin_43945983/article/details/110882142