mysql中的update语句
我想将新数量(100)添加到产品的现有数量。 这给了我一个这样的错误 '不能在FROM子句中为更新指定目标表'product''mysql中的update语句,mysql,subquery,Mysql,Subquery,我想将新数量(100)添加到产品的现有数量。 这给了我一个这样的错误 '不能在FROM子句中为更新指定目标表'product'' 如何修复此问题???您只需执行以下操作: update product set qty=100 + (select qty from product p where p.name='abc' and p.weight='100g') where name='abc' and weight='100g' update product set qty= qty +
如何修复此问题???您只需执行以下操作:
update product
set qty=100 + (select qty from product p where p.name='abc' and p.weight='100g')
where name='abc' and weight='100g'
update product
set qty= qty + 100
where name='abc' and weight='100g'