CREATE TRIGGER google_inventory BEFORE UPDATE ON `cataloginventory_stock_item`
FOR EACH ROW
BEGIN
update `catalog_product_entity_int`
set value=20
where attribute_id=552
and entity_id=NEW.product_id
and NEW.is_in_stock=0;
update `catalog_product_entity_int`
set value=21
where attribute_id=552
and entity_id=NEW.product_id
and NEW.is_in_stock=1;
END;
它给了我以下错误:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4
我是一名 SQL Server 专业人士,无法确定问题所在。
最佳答案
您需要更改分隔符。没有它,分号将结束 CREATE TRIGGER 语句。
delimiter |
CREATE TRIGGER google_inventory BEFORE UPDATE ON `cataloginventory_stock_item`
FOR EACH ROW
BEGIN
update `catalog_product_entity_int`
set value=20
where attribute_id=552
and entity_id=NEW.product_id and NEW.is_in_stock=0;
update `catalog_product_entity_int`
set value=21
where attribute_id=552
and entity_id=NEW.product_id and NEW.is_in_stock=1;
END;
|
delimiter ;
关于mysql - 这个mysql create trigger语句有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10049401/