我有两个表 stock 和 order ,我试图让触发器工作,以便在下订单后,订单数量会从库存数量字段中删除。
DELIMITER $$
CREATE TRIGGER stock_update
AFTER INSERT ON order
FOR EACH ROW
BEGIN
SET @quantity = NEW.quantity
UPDATE stock s;
SET s.quantity = OLD.quantity - NEW.quantity
FROM stock s, order o
WHERE s.ID_stock = o.ID_stock;
END;
$$
DELIMITER;
但我只是收到错误号 1064