Answer the question
In order to leave comments, you need to log in
How to delete in MySQL triggers?
Cannot delete rows whose count data is less than or equal to 0. When updating a row, it throws error 1442.
CREATE TRIGGER `tr1` AFTER UPDATE ON `test`
FOR EACH ROW
BEGIN
DELETE FROM `test` WHERE `count`<=0;
END;
Answer the question
In order to leave comments, you need to log in
No, it's impossible. You cannot make edits in the table for which the trigger is created (except for editing the current row):
In general, you cannot modify a table and select from the same table in a subquery.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question