I have a 2 tables called ‘members’ and ‘users’ that both have 2 columns: name & gender. I want that everytime I add a new ‘name’ to members table, the value in ‘gender’ column in that row would be updated from ‘users’ table:
**users:**
Emilia - F
John - M
David - M
**members:**
Synthia - F
'INSERT INTO members VALUES('David')...or whatever'
now **members:**
Synthia - F
David - M
You could use an insert trigger. However you should not have a copy of the gender in two different tables – it breaks normalization, requires more storage space and risks that the two copies will get out of sync.
Instead you should use a foreign key and join the tables when you need information from both. You can use the username as the foreign key, or the autoincrement id, if you have one.