mysql - How can I Update column value to Old value plus New value from other table using Trigger? -


how can update column value old value plus new value other table using trigger if value has have entry? wanted following. notice bold , italicized part.

delimiter$$ create trigger trigger_name after insert on table_one each row begin   insert table_two(clmn_id, clmn_one) values(new.clmn_id_fk,new.clmn_a)   on duplicate key update clmn_one = values(clmn_one + new.clmn_a); end$$ delimiter;

try removing keyword values on duplicate key:

delimiter$$ create trigger trigger_name after insert on table_one each row begin   insert table_two(clmn_id, clmn_one) values(new.clmn_id_fk,new.clmn_a)   on duplicate key update fine_amount = clmn_one + new.clmn_a; end$$ delimiter; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -