Mybatis根据List批量更新

    <!--批量更新-->
    <update id="updateList">
        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
            update user
            <trim prefix="SET" suffixOverrides=",">
                <if test="item.age!= null ">age= #{item.age},</if>
                <if test="item.name!= null  and item.name!= ''">name= #{item.name},</if>
            </trim>
            where id= #{item.id}
        </foreach>
    </update>
发布了206 篇原创文章 · 获赞 45 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/corleone_4ever/article/details/105092460