我有一个似乎不想作为触发器运行的SQL语句,它允许将其存储为触发器,但它不会进行任何更改,它已被添加到带有phpmyadmin on table的数据库中ebaylinked'更新后开火
CREATE TRIGGER `Update` AFTER UPDATE ON `ebaylinked`
FOR EACH ROW UPDATE product
INNER JOIN ebaylinked e ON ebaylinked.ebay_ID = product.eBay_ID
SET product.product_stock =product.product_stock - ebaylinked.QuantitySold,
ebaylinked.Processed=0
WHERE
ebaylinked.Processed = 1
有谁知道什么是错的?
答案 0 :(得分:0)
不确定为什么你拥有inner join
但是你可以尝试以下方法,这应该更新product_stock并在产品表中进行处理,其中产品的id =已更新的产品ID:
CREATE TRIGGER `Update` AFTER UPDATE ON `ebaylinked`
FOR EACH ROW UPDATE product
SET product.product_stock =product.product_stock - ebaylinked.QuantitySold,
ebaylinked.Processed=0
WHERE
ebaylinked.Processed = 1 and product.eBay_ID = new.eBay_ID