I need to update the parent item's updated_at field when any of it's child item's updated_at field is updated.
DELIMITER $$
CREATE TRIGGER after_item_update
AFTER UPDATE
ON item FOR EACH ROW
BEGIN
IF OLD.updated_at <> NEW.updated_at AND OLD.parent_id > 0 THEN
UPDATE item i set updated_at = now() where i.id = OLD.parent_id;
END IF;
END$$
DELIMITER ;
I tried above query but it gives me following error when I try to update any row from the table.
ERROR 1442 (HY000): Can't update table 'item' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.```