I want the epc column epc always be earnings / clicks . I am using the AFTER UPDATE trigger to accomplish this. Therefore, if I added 100 clicks to this table, I would like the EPC to automatically update.
I am trying to do this:
CREATE TRIGGER `records_integrity` AFTER UPDATE ON `records` FOR EACH ROW SET NEW.epc=IFNULL(earnings/clicks,0);
And getting this error:
MySQL said:
I also tried to use OLD, but also got an error. I could do BEFORE, but if I added 100 clicks, it would use the previous # clicks for the trigger (right?)
What should I do to do this?
EDIT is an example of a query that will run on this:
UPDATE records SET clicks=clicks+100 //EPC should update automatically
sql mysql triggers
hellohellosharp
source share