0
CREATE TRIGGER del
AFTER UPDATE
   ON simple_trigger FOR EACH ROW

BEGIN

   DELETE FROM simple_trigger WHERE id=1;

END//

I think code is correct but Mysql don't let me to update my row.

Mysql Error

1442 - Can't update table 'simple_trigger' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

Puskal
  • 71
  • 1
  • 3
  • Could you provide some more context as to why your row isn't updating? Do you get error messages? Do you get any output back from MySQL that would indicate that the query executed? Does id 1 still exist in your table? – Makoto Dec 05 '14 at 04:11
  • #1442 - Can't update table 'simple_trigger' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. yes I have id 1 in my table. Whenever I try to execute my sql statement for update I get above error message. – Puskal Dec 05 '14 at 04:21
  • You can not do insert/update/delete on the same table where the trigger is getting executed. – Abhik Chakraborty Dec 05 '14 at 06:56
  • Possible duplicate of [MySQL trigger set values for NEW row and update another in the same table](https://stackoverflow.com/questions/11247590/mysql-trigger-set-values-for-new-row-and-update-another-in-the-same-table) – Nabeel Ahmed Jun 14 '17 at 10:25

0 Answers0