0

私は2つのテーブルを持っています。最初のテーブルにはShipping、列ProductQuantityおよびがありIDます。2 番目のテーブルにはInventory、列ProductとがありますTotal

の値を取得し、値が各テーブルで一致し、urlの値であるWHERE の値Shipping.Quantityから減算したい( )。次に、その製品の Inventory.Total として新しい値を設定します。 Inventory.TotalProductShipping.ID$onum

私が思いつくことができる最高のもの:

UPDATE Inventory.Total 
CROSS JOIN Shipping 
SET Inventory.total=(Inventorytotal-Shipping.Quantity) 
WHERE Inventory.Product=Shipping.Product 
  AND Shipping.ID=$onum
4

1 に答える 1

1
UPDATE Inventory join Shipping 
ON Inventory.Product=Shipping.Product 
SET Inventory.Total=Inventory.Total-Shipping.Quantity
WHERE Shipping.ID=$ID
于 2012-11-05T16:16:25.193 に答える