<update id="updateBatchById">
<foreach collection="list" item="item" separator=";">
update
`t_student`
set
`name` = #{item.name},
`age` = #{item.age}
where
id = #{item.id}
</foreach>
</update>
spring.datasource.url=jdbc:mysql://localhost:3306/test?allowMultiQueries=true
update `t_student`
<trim prefix="set" suffixOverrides=",">
<trim prefix=" `name` = case " suffix=" end, ">
<foreach collection="list" item="item">
<if test="item.name != null">
when `id` = #{item.id} then #{item.name}
</if>
</foreach>
</trim>
<trim prefix=" `age` = case " suffix=" end, ">
<foreach collection="list" item="item">
<if test="item.age != null">
when `id` = #{item.id} then #{item.age}
</if>
</foreach>
</trim>
</trim>
where
`id` in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item.id}
</foreach>
UPDATE `t_student`
SET `name` =
CASE
WHEN `id` = 1 THEN
'张三'
WHEN `id` = 2 THEN
'李四'
WHEN `id` = 3 THEN
'王五'
WHEN `id` = 4 THEN
'赵六'
END,
`age` =
CASE
WHEN `id` = 1 THEN
40
WHEN `id` = 2 THEN
34
WHEN `id` = 3 THEN
55
WHEN `id` = 4 THEN
76
END
WHERE
`id` IN ( 1, 2, 3, 4 )
免责申明:
本文系转载,版权归原作者所有,如若侵权请联系我们进行删除!
《数据治理行业实践白皮书》下载地址:https://fs80.cn/4w2atu
《数栈V6.0产品白皮书》下载地址:https://fs80.cn/cw0iw1
想了解或咨询更多有关袋鼠云大数据产品、行业解决方案、客户案例的朋友,浏览袋鼠云官网:https://www.dtstack.com/?src=bbs
同时,欢迎对大数据开源项目有兴趣的同学加入「袋鼠云开源框架钉钉技术群」,交流最新开源技术信息,群号码:30537511,项目地址:https://github.com/DTStack