MYSQL仅选择带有触发器的已编辑行,然后插入到另一个表中

时间:2018-12-04 07:54:58

标签: mysql triggers

我需要创建一个触发器,对于一个表上的每次更新,将一行或多行更新写入另一张表。我创建了此触发器:

CREATE TRIGGER update_order_trigger
AFTER UPDATE ON sales_order
FOR EACH ROW
INSERT INTO update_status_order (order_id, n_ordine, status, reparto)
SELECT o.order_id, s.increment_id, s.status, c.value
FROM catalog_product_entity_varchar c INNER JOIN sales_order_item o INNER 
JOIN sales_order s
ON o.product_id = c.entity_id 
WHERE c.attribute_id = 154 AND s.entity_id = o.order_id
GROUP BY o.order_id, c.value, s.increment_id;

执行此触发器时,它将所有行从表sales_order复制到update_status_order。我该怎么做才能只复制已编辑的行?

0 个答案:

没有答案