私は2つのテーブルを持っています。最初のテーブルにはShipping
、列Product
、Quantity
およびがありID
ます。2 番目のテーブルにはInventory
、列Product
とがありますTotal
。
の値を取得し、値が各テーブルで一致し、urlの値であるWHERE の値Shipping.Quantity
から減算したい( )。次に、その製品の Inventory.Total として新しい値を設定します。 Inventory.Total
Product
Shipping.ID
$onum
私が思いつくことができる最高のもの:
UPDATE Inventory.Total
CROSS JOIN Shipping
SET Inventory.total=(Inventorytotal-Shipping.Quantity)
WHERE Inventory.Product=Shipping.Product
AND Shipping.ID=$onum