I want the
CREATE TRIGGER `records_integrity` AFTER UPDATE ON `records` FOR EACH ROW SET
MySQL said: #1362 - Updating of NEW row is not allowed in after trigger
UPDATE records SET clicks=clicks+100
//EPC should update automatically
You can't update rows in the table in an after update trigger.
Perhaps you want something like this:
CREATE TRIGGER `records_integrity` BEFORE UPDATE ON `records` FOR EACH ROW SET NEW.epc=IFNULL(new.earnings/new.clicks, 0);
Inside a trigger, you have have access to
OLD are the old values in the record and
NEW are the new values. In a before trigger, the
NEW values are what get written to the table, so you can modify them. In an after trigger, the
NEW values have already been written, so they cannot be modified. I think the MySQL documentation explains this pretty well.