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
-- 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$$
It is working, but is displaying the number before. For example
Insert into table 1, id = 15. In table 2 returns 14. Any ideas?