需求:
如何将多条update语句合并为一条update语句:
如,update table1 set col='2012' where id='2014001'
      update table1 set col='1009' where id='2014003'
如何合并为一条?
 
在网上找了好久,总结了一个相对简单的语句(有些语句是函数语句,有点晕),如下:
  update table1 set col=(case id 
  when '2014001' then '2012'
  when '2014003' then '1009' end)
  where  id in('2014001','2014003')
这个还可以扩展为多个字段的,这个你自己去依葫芦画瓢了~
 

相关文章:

  • 2022-12-23
  • 2021-06-01
  • 2021-08-26
  • 2021-08-29
  • 2021-10-03
  • 2021-08-04
  • 2022-12-23
猜你喜欢
  • 2022-02-01
  • 2022-01-26
  • 2022-12-23
  • 2021-11-14
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案