title: mysql - after insert trigger to insert data into other table
body: <pre><code>I have two tables - 
  
  League        (lg_id, lg_Userid, lg_JoinDate)
  </code></pre>
  
  <p>Here, <code>lg_id</code> is PK and its auto incremented.</p>
  
  <pre><code>LeagueMember  (lgMbr_lg_id, lgMbr_Userid, lgMbr_JoinDate) 
  </code></pre>
  
  <p><code>lgMbr_lb_id</code> is a FK referencing <code>League(lg_id)</code></p>
  
  <p>After a row is inserted into League table, a corresponding row should be inserted into leagueMember with the same <code>lg_id</code> which was inserted  into League table. I am trying to create an after insert trigger for this.</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>I tried this but it doesn't work. Whats wrong here?</p>
  
  <p>Edit - </p>
  
  <p>I receive an error message which says there's an error with my syntax. Based on this <a href="http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html" rel="nofollow">mysql create trigger reference page</a> I even tried this, but I still get a syntax error.    </p>
  
  <pre><code>CREATE TRIGGER trigger_league AFTER INSERT ON `League` 
  FOR EACH ROW 
  BEGIN 
      INSERT INTO `LeagueMember` SET lgMbr_lg_id = NEW.lg_id;    
  END;
  </code></pre>