MyBatis中in 的使用方法

MyBatis中使用in关键字参数为集合时,需要使用到foreach标签。
下面详细介绍以下foreach标签的几个参数

foreach属性.png

实例:
    <select id="getNewListByLabelID" resultMap="BaseResultMap" parameterType="arraylist">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tb_problem
        WHERE id IN
        <foreach collection="ids" index="index" item="id" separator="," close=")" open="(">
            #{id}
        </foreach>
    </select>


作者:小安的大情调
链接:https://www.jianshu.com/p/4265d5e0df3f
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
原文地址:https://www.cnblogs.com/zhuyeshen/p/11981770.html