mysql - Trigger to change all the rows after an update is done -
having table name transitions, i want change values of rows after update made.
i'm using following trigger, changes row i'm making update to.
create trigger signaturetrigger before update on `transactions` each row begin set new.signature = '288'; end i'm trying change rows signature = 288, how can modify trigger in order archieve that? thought using for each row enough.
thanks in advance.
you can use after update trigger update statement:
create trigger signaturetrigger after update on `transactions` each row begin update transactions set new.signature = '288'; end; this seem strange thing do, however.
consider alternative: add updatedat column table , update signature in row. then, when want recent signature use:
select signature transactions order updatedat desc limit 1; an index on transactions(updatedat, signature) make quite speedy. and, update go much, faster updating rows.
Comments
Post a Comment