我有两张桌子。第一个表Shipping包含列Product,Quantity和ID。第二个表是Inventory列Product和Total。
我想取 的值Shipping.Quantity并从Inventory.TotalWHERE 中的值减去Product每个表中的值匹配并且Shipping.ID是 url ( $onum) 中的值。然后我想将该产品的新值设置为 Inventory.Total。
我能想到的最好的:
UPDATE Inventory.Total
CROSS JOIN Shipping
SET Inventory.total=(Inventorytotal-Shipping.Quantity)
WHERE Inventory.Product=Shipping.Product
AND Shipping.ID=$onum