I'm trying to write a trigger for calculating the average rating of an institution.
The idea is this:
When an impressin is added to the table, the average score should be calculated using the AVG function. Code:
CREATE TRIGGER 'ratein_up' AFTER INSERT ON 'impressin'
FOR EACH ROW
BEGIN
SET @new_rat:=(SELECT AVG(Rating) FROM impressin);
UPDATE feed-point SET OLD.AverageRating = @new_rat
WHERE id= NEW.idFeedPoint;
END
Indicates an error in the line:UPDATE feed-point SET OLD.AverageRating = @new_rat WHERE id= NEW.idFeedPoint;
update, you are attempting to update a row in the source table in an after update trigger.