title: MySQL Triggers last_insert_id()
body: <p>I have table 1 in which has id as autoincrement.
  Table 2 has a foreign key relationship to Table 1, in which I need that value generated from table 1 to be inserted into table 2</p>
  
  <pre><code>-- Trigger DDL Statements
  DELIMITER $$
  
  USE `baemer_emr`$$
  
  CREATE TRIGGER `baemer_emr`.`after_insert_log` AFTER INSERT ON `baemer_emr`.`table1`
  FOR EACH ROW
  BEGIN
    INSERT INTO table2 VALUES (last_insert_id() , something);
  END$$
  </code></pre>
  
  <p>It is working, but is displaying the number before. For example</p>
  
  <p>Insert into table 1, id = 15. In table 2 returns 14. Any ideas?</p>