postgres 批量更新内容

Posted 鱼儿慢慢游~~

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了postgres 批量更新内容相关的知识,希望对你有一定的参考价值。

在程序中遇到这样的需求, 数据库表格式如下

需要把批量更新status, 如name = fox 时, status = 1, name = boa 时,status = 2 .... 类似的

postgres 的写法如下:

update 表名 set status = case name 
        when \'dodo\' then \'1\'  
        when \'eel\' then \'1\' 
       end 
     where name in(\'dodo\', \'eel\');
        

  

 

以上是关于postgres 批量更新内容的主要内容,如果未能解决你的问题,请参考以下文章