扫码关注官方订阅号
item表里有个int类型的字段sales,如何使用sql更新销量sales,当字段sales为null时设置为数字quantity,否则设置sales为原sales+quantity?
解决了
UPDATE `item` SET `item`.`sales` = IFNULL(`item`.`sales`, 0)+2 WHERE `item`.`id` = 2;
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
解决了