mybatis批量插入写法
sql
UPDATE tb_book
SET
update_time = CASE book_id
WHEN 1101 THEN 123123112
WHEN 1102 THEN 123123132
END
WHERE book_id IN (1101,1102)
上下对照写 xml
<update id="updateBatch">
update tb_book set
update_time =
<foreach collection="list" item="item" index="index"
separator=" " open="case book_id" close="end">
when #{item.bookId} then #{item.updateTime}
</foreach>
where book_id in
<foreach collection="list" item="item" index="index"
separator="," open="(" close=")">
#{item.bookId}
</foreach>
</update>