触发不更新另一个表

时间:2019-08-29 13:35:06

标签: mysql triggers

我正在尝试以这种方式更新第二张表

我有2张桌子

fr_hikashop_product: product_id,product_size_values(varchar(50))

fr_hikashop_product_category: id(自动递增), product_id, category_id, category_parent_id

和触发器

CREATE TRIGGER trg_product_size AFTER UPDATE ON fr_hikashop_product
FOR EACH ROW
BEGIN
delete from fr_hikashop_product_category where category_id between 441 and 448 AND product_id = OLD.product_id;
insert ignore into fr_hikashop_product_category (product_id,category_id,category_parent_id) select NEW.product_id,441, 400 from fr_hikashop_product where product_size_values like '%41%' AND product_id = NEW.product_id;
insert ignore into fr_hikashop_product_category (product_id,category_id,category_parent_id) select NEW.product_id,442, 400 from fr_hikashop_product where product_size_values like '%42%' AND product_id = NEW.product_id;
etc ... up to 48
END //

让product_size_values = '41,43'

什么都没有发生,没有错误,但是我在表fr_hikashop_product_category中没有得到2个新行

感谢您的帮助

0 个答案:

没有答案