MyBatis批量更新,update设置多个字段值,where条件为集合
程序员文章站
2022-03-03 21:45:31
...
import org.apache.ibatis.annotations.Param; //接口 void setStaff(@Param("channels")List<ChatChannel> channels, @Param("staffId") String staffId, @Param("staffName") String staffName);
<update id="setStaff" > UPDATE chat_channel SET staff_id = #{staffId}, staff_name = #{staffName} WHERE id IN <foreach collection="channels" index="index" item="item" open="(" separator="," close=")"> #{item.id} </foreach> </update>