I have two tables -
League (lg_id, lg_Userid, lg_JoinDate)
Here, lg_id is PK and its auto incremented.
LeagueMember (lgMbr_lg_id, lgMbr_Userid, lgMbr_JoinDate)
lgMbr_lb_id is a FK referencing League(lg_id)
After a row is inserted into League table, a corresponding row should be inserted into leagueMember with the same lg_id which was inserted into League table. I am trying to create an after insert trigger for this.
CREATE TRIGGER trigger_league AFTER INSERT ON `League`
FOR EACH ROW
BEGIN
INSERT INTO `LeagueMember` (`lgMbr_lg_id`, `lgMbr_Userid`,`lgMbr_JoinDate`) values (NEW.lg_id,NEW.lg_UserId,'2000-10-10')
END;
I tried this but it doesn't work. Whats wrong here?
Edit -
I receive an error message which says there's an error with my syntax. Based on this mysql create trigger reference page I even tried this, but I still get a syntax error.
CREATE TRIGGER trigger_league AFTER INSERT ON `League`
FOR EACH ROW
BEGIN
INSERT INTO `LeagueMember` SET lgMbr_lg_id = NEW.lg_id;
END;