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

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -