Insert same data into two Mysql columns

Asked

Viewed 264 times

0

Hello! I have a table with the name tabx and two columns y and z, when I insert the values in the column y I need a Trigger to copy this value to the column z. I have tried some solutions but without success someone can help me?

  • It’s like you put what you tried here?

  • Are you in need of this for a manual Insert or are you developing software? The simple fact of putting the variable name in the place of the column does not solve? say the name of the variable you will put in the column y be it k then the Insert would look like this: insert into tabx (y, z) values (k, k) just so you know...

1 answer

2


+or- this

CREATE TRIGGER ins_table BEFORE INSERT ON table FOR EACH ROW BEGIN SET NEW. z = new. y; END;//

  • Try to elaborate a more explanatory answer. :]

  • Perfect Motta solved my problem. Thank you very much!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.