0
点赞
收藏
分享

微信扫一扫

数据库语句合并执行修改操作


如何将我们的SQL语句的修改操作来合并执行呢,很简单,我们只需要使用when即可。

update blog set title='第一条' where id=1

update blog set title='第二条' where id=2

update blog set title='第三条' where id=3

转换如下:

update  blog  set title = ( case id              
when '1' then '改第一条'
when '2' then '改第二条'
when '3' then '改第三条'
end )
where id in ('1','2','3')

如此,便可以了


举报

相关推荐

0 条评论