时间:2021-07-01 10:21:17 帮助过:32人阅读
(2)使用case when实现
实际的sql格式
UPDATE course SET name = CASE id WHEN 1 THEN ‘name1‘ WHEN 2 THEN ‘name2‘ WHEN 3 THEN ‘name3‘ END, title = CASE id WHEN 1 THEN ‘New Title 1‘ WHEN 2 THEN ‘New Title 2‘ WHEN 3 THEN ‘New Title 3‘ END WHERE id IN (1,2,3)
<update id="updateSortBatch" parameterType="java.util.List"> update t_banner_record <trim prefix="set" suffixOverrides=","> <trim prefix="sort_id=case" suffix="end,"> <foreach collection="list" item="banner" index="index"> when id=#{banner.id} then #{banner.sortId} </foreach> </trim> </trim> where id in <foreach collection="list" item="banner" index="index" separator="," open="(" close=")"> #{banner.id} </foreach> </update>
SQL(1) 批量处理
标签:span pre when 批量更新 multi 批量处理 end name font