mybatis中写sql语句的注意事项--批量修改数据

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Gr_lbxx/article/details/81088803

本人执行sql时,如果在 close="end;" 后添加separator=“;” ,而where条件没有添加;时,执行的sql语句中最后一个update无法添加分号,所以正确执行就在where条件后面加分号,不添加separator=“;”。

<update id="" parameter="list">

update 表名

       <foreach collection="list" item="item" index="index"  open="begin"  close="end;" >

            <set>

                name=#{item.name}

           </set>

         where id=#{item.id};

    </foreach>

</select>

猜你喜欢

转载自blog.csdn.net/Gr_lbxx/article/details/81088803