I have two tables:
userstrainer
In the users table, I have a column is_trainer=false by default`.
When a user inputs the information in the table users and chooses the column is_trainer=true I want to insert the user information in the trainer table.
When I omit the if condition, after I insert a user in the users table it puts the information in the trainer table, but when I put if condition, it cannot work! I think it thinks that is_trainer is for the trainer table not for the users table
My code:
BEGIN
IF NEW.is_trainer <> OLD.is_trainer THEN
INSERT INTO trainer(trainer_id, sport_id, fee_per_hour, experience, created_by)
VALUES(users.user_id, 3, '200$', 3, 6);
END IF;
RETURN NEW;
END;