DROP TRIGGER IF EXISTS `db_name`.`ins_ratings_update`//
CREATE TRIGGER `db_name`.`ins_ratings_update` AFTER INSERT ON `db_name`.`ratings`
FOR EACH ROW BEGIN
UPDATE aggregate_storing_table ast SET rating = (SELECT AVG(score) FROM individual_rating_record_table WHERE ast_id=NEW.ast_id);
END
//
Thursday, November 06, 2008
Using triggers to auto-update aggregates with MYSQL
Del.icio.us Add to del.icio.us
Digg DiggIt!
Reddit Reddit
Stumbleupon Stumble This
Google Bookmarks Add to Google Bookmarks
Yahoo My Web Add to Yahoo MyWeb
Technorati Add to Technorati Faves
Slashdot Slashdot it
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment