I need to change this trigger to point to the column that just got updated so what do I change NEW.song_id to?? Thanks!
DROP TRIGGER IF EXISTS `ratings_update`//
CREATE TRIGGER `ratings_update` AFTER UPDATE ON `ratings2`
FOR EACH ROW update SONGS set
rating_sum = rating_sum + NEW.rating,
rating = rating_sum / rating_count
where id = NEW.song_id
//
EDIT vvv
DROP TRIGGER IF EXISTS `ratings_upd`//
CREATE TRIGGER `ratings_upd` AFTER UPDATE ON `ratings2`
FOR EACH ROW update SONGS set
rating_sum = rating_sum + NEW.rating - OLD.rating,
rating_count = rating_count,
rating = rating_sum / rating_count
where id = NEW.song_id
//
This is what I came up with for my trigger but it is throwing me this error when I run it..
OLDaccesses values before the update, andNEWaccesses values after the update.From http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html: