我有以下觸發:MySQL的觸發器不能更新表 - 收到錯誤1442
CREATE TRIGGER sum
AFTER INSERT
ON news
FOR EACH ROW
UPDATE news SET NEW.sum = (NEW.int_views + NEW.ext_views)/NEW.pageviews
它總結表的int_views
和ext_views
柱和由總瀏覽量將其劃分。
每當我嘗試一個新的行添加到消息,我得到以下錯誤:
ERROR 1442 (HY000) at line 3: Can't update table 'news' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
觸發看起來很簡單我。是否有觸發器無法運行的原因?
沒有'where'條件? – jcho360
@ jcho360,對不起,我沒有看到哪裏包括哪裏條件。插入後,我希望觸發器在每一行都執行。 – egidra
如果這不起作用讓我知道嘗試與'WHERE news_id = NEW.news_id;'在末尾 – jcho360