0
点赞
收藏
分享

微信扫一扫

Oracle + MyBatis 批量更新 update

zidea 2023-10-20 阅读 27
<update id="updateUserDO' parameterType="list"> 
<foreach collection="list" item="param" separator="" open="begin" close="end;">
        update user
        <set>
        <if test="null!=param.account and ''!=param.account">
         account =#{param.account},
        </if>
        <if test="null!=param.userName and ''!=param.userName">
        user_name =#{param.userName},
        </if>
    </set>
    where uuid = #{param.uuid};
</foreach>
</update>

注意:where最后有个分号
其实最后SQL格式就是
begin
update xxx set xxx where xxx;
update xxx set xxx where xxx;
end;
是一个SQL块

举报

相关推荐

0 条评论