摘要.
使用 case when:
UPDATE cp_system_param SET `value`=CASE WHEN cp_system_param.`code`='system_name' THEN 'aa' WHEN cp_system_param.`code`='system_title' THEN 'bb' WHEN cp_system_param.`code`='web_flg' THEN 'cc' ELSE `value` END```
注意:这里SQL如果不加 ELSE END会导致别的字段值为空:
![](https://img-blog.csdn.net/20180704164707330?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjQ0NzM3Mw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
![](https://img-blog.csdn.net/20180704160225946?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjQ0NzM3Mw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
[https://blog.csdn.net/weixin_42447373/article/details/80914203](https://blog.csdn.net/weixin_42447373/article/details/80914203)
[https://blog.csdn.net/weixin_42447373/article/details/80914203](https://blog.csdn.net/weixin_42447373/article/details/80914203)