我有两个表“basket_products”和“products”。我想用“basket_products”“adet”列更新“products”表的“adet”列。我想更新basket_products.urun = products.urun的行。 我想使用此代码并收到错误:“多部分标识符”basket_products.urun“无法绑定。”
update products
set adet = adet - (
select basket_products.adet
from basket_products
inner join products
on products.urun = basket_products.urun)
where products.urun = basket_products.urun
怎么了?
答案 0 :(得分:1)
试试这个:
更新p 设置p.adet = bp.adet 来自产品p 加入basket_products bp 在p.urun = bp.urun