update StoreStock
set QTY = QTY + $QTY
where whStock.QTY >= $QTY
and StoreStock.PNR = '$prod'"
我将如何运行此错误 我所拥有的是,whStock表的外键是Products表和StockStock外键是whStock
答案 0 :(得分:0)
据我了解,您需要在Products
表更新期间检查StockStock
表中的条件。
假设StockStock
表的外键whStock
引用ID
表中的Products
列
update StoreStock s
set QTY = QTY + $QTY
where exists (select 1 from Products p where p.ID = s.whStock and p.QTY >= $QTY)
and s.PNR = '$prod'