一、根据id更新多个字段
<update id="batchUpdate">
update food
<trim prefix="set" suffixOverrides=",">
<trim prefix="open_id =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.openId}
</foreach>
</trim>
<trim prefix="create_by =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.createBy}
</foreach>
</trim>
</trim>
where id in
<foreach collection="list" index="index" item="item"
separator="," open="(" close=")">
#{item.id}
</foreach>
</update>
更多【mybatis-mybatis根据批量更新多个字段】相关视频教程:www.yxfzedu.com