Update product.tblproductinformation
SET Quantity = (Quantity-1)
where(Select iProduct.ProductID
from tblindividualproduct as iProduct
INNER JOIN tblproductinformation as pInfo ON iProduct.Code = pInfo.Code) = @p1"
我想更新我的数量以减去1.我还包括内连接,因为我的位置在另一个表中。我收到了一个错误:
You cant specify target table 'tblproductinformation' for update in FROM clause
出了什么问题?
答案 0 :(得分:1)
您可以使用多表UPDATE
语法直接连接表:
UPDATE tblproductinformation AS pInfo
JOIN tblindividualproduct AS iProduct ON iProduct.Code = pInfo.Code
SET pInfo.Quantity = pInfo.Quantity - 1
WHERE iProduct.ProductID = @p1