mysql - Updating table in trigger after update on the same table -
how can update table's column in trigger after update on same table?
here's trigger:
create trigger upd_total_votes after update on products_score each row update products_score set products_score.votes_total = (select (votes_1 + votes_2 + votes_3 + votes_4 + votes_5) products_score id = new.id)
now when update table like
update products_score set votes_1 = 5 id = 0
this doesn't work, following:
#1442 - can't update table 'products_score' in stored function/trigger because used statement invoked stored function/trigger.
so how on earth can work?
if change trigger before
instead of after
this:
create trigger upd_total_votes before update on products_score each row begin set new.votes_total = new.votes_1 + new.votes_2 + new.votes_3 + new.votes_4 + new.votes_5 end ;
Comments
Post a Comment