There are a lot of questions about LAST_INSERT_ID()
In my case, issue is:
When INSERT
is followed by SELECT LAST_INSERT_ID()
there are no records being inserted
INSERT INTO sequences (state) VALUES (0);
select LAST_INSERT_ID();
>>> 80 // nothing is added to DB
INSERT
on it's own works OK
INSERT INTO sequences (state) VALUES (0);
>>>
select LAST_INSERT_ID();
>>> 81 // row is inserted
For testing I am using SequelPro, DB is Amazon's RDS MySQL. Same issue happens when I use Python's MySQLdb module.
Ideally I want to insert row, get back ID of it for future identification and use.