当前位置:Gxlcms >
数据库问题 >
【sql技巧】mysql修改时,动态指定要修改的字段 update `table` set (case when ....) = 1 where id = xx
【sql技巧】mysql修改时,动态指定要修改的字段 update `table` set (case when ....) = 1 where id = xx
时间:2021-07-01 10:21:17
帮助过:43人阅读
message
SET send_status
= (
CASE WHEN sender_id
= #{userId, jdbcType
=BIGINT}
THEN 2 ELSE send_status
END),
receive_status = (
CASE WHEN receiver_id
= #{userId, jdbcType
=BIGINT}
THEN 2 ELSE receive_status
END)
WHERE dialog_id
IN (
<foreach collection
="list" item
="item"
index="
index" separator
=","
>
#{item, jdbcType=BIGINT}
</foreach
>
)
我这里用的是mybatis,批量修改。
工作中遇到的,希望能帮助同样困惑的人
【sql技巧】mysql修改时,动态指定要修改的字段 update `table` set (case when ....) = 1 where id = xx
标签:set list collect question over t-sql dia com div