MYSql触发器不对db进行任何更改

时间:2016-01-11 07:23:37

标签: mysql triggers

我有一个似乎不想作为触发器运行的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

有谁知道什么是错的?

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