在程序中遇到这样的需求, 数据库表格式如下
需要把批量更新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');
在程序中遇到这样的需求, 数据库表格式如下
需要把批量更新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');
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。