0

I have written a trigger to delete all rows older that 1 day in the table on every insert. But whenever I insert a new row, it is throwing the following error

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

Here is the trigger I wrote

CREATE TRIGGER delete_testing
AFTER INSERT ON example
FOR EACH ROW
DELETE FROM example
WHERE date_created < DATE_SUB(NOW(), INTERVAL 1 DAY)
Sarthak
  • 188
  • 1
  • 2
  • 14

0 Answers0