mysql - How can I write a trigger that can copy new row from a table on insertion to another table? -


i have 2 tables, creds , users.

users

email password fullname contact city

creds

email password

i need trigger can copy email , password users creds upon insertion of new rows.

hope following trigger works you. more or less this

create trigger user_trigger on creds  insert   begin      insert users(email, password, fullname, contact, city)      select distinct u.email, u.password     inserteduser u     left join creds c     on u.email = c.email , u.password = c.password end; 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -