I have two tables with the following column names.
users
ui | email | pass
user_profiles
_email | qty | lvl
I am attempting to make sure that everytime a new user is added to the users table that the user_profiles table creates a new row for the new user. However it fails. After reading through many sample trigger statements I can’t seem to find the error.
CREATE TRIGGER updatUserProfilesTBL AFTER INSERT ON users
BEGIN
INSERT INTO user_profiles (_email)
VALUES (new.email)
END;
Looks like you are missing the
FOR EACH ROW. Additionally, you will need to alter theDELIMITERif executing this through the MySQL command line and add a;after the insert statement.According to the
CREATE TRIGGERspec, it is not optional.