I want to update a table which is also tied on a "after delete" trigger.
DELIMITER §
CREATE TRIGGER sorting
AFTER DELETE ON tb_number
FOR EACH ROW
BEGIN
UPDATE tb_number SET number1 = number1 - 1 WHERE number1 >= old.number1;
END §
DELIMITER ;
DELETE FROM tb_number where number1 = 2;
Why does not work this? It says:
Error Code: 1442. Can't update table 'tb_number' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
So how can I fix this with trigger? I thought, after-delete means: Once a deletion has been executed, the trigger will update...