I want to see new records and updates entered in the log table, I created a trigger for this but I get error 1442. Can you help me, please?
CREATE TRIGGER `trigger_changes`
AFTER UPDATE ON `customers`
FOR EACH ROW
Update customers c INNER JOIN cust_changes ch ON ch.id = c.id SET ch.name = c.name
1442 – Can’t update table ‘cust_changes’ in stored function/trigger because it is already used by statement which invoked this stored function/trigger
2
Answers
You have to reference the data in the trigger using the pseudo table name OLD or NEW.
If you use OLD.id (or NEW.id) in the updated statement then mysql (as @PeterHe) suggested is happy. If your model is different or you are doing something different then you need to tell us.
As expected with no errors. Please add your versions for mysql and phpmyadmin.