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;
它給了我下面的錯誤:有什麼不對這個MySQL創建觸發器聲明
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的傢伙,不能把我的手指上的問題是什麼。
是什麼NEW.product_id和NEW.is_in_stock?是否來自另一個表,如果是這樣,那麼你需要加入它 – Taryn 2012-04-06 21:23:53
新的觸發器語法是指根據此文檔在表中進行的更改http://dev.mysql.com/doc/refman /5.0/en/create-trigger.html – RThomas 2012-04-06 21:24:47