I want to execute a query of the form:
INSERT INTO table(field1, field2) SELECT field1, field2 FROM table WHERE id IN ( 4, 8, 15, 16, 23, 42 )
Where id is the auto_increment'ing primary key of table
.
After executing this statement, I want to know what all the new id's that just got generated are. How can I recover this information? I'm interested in (maybe) doing this in a stored procedure and returning the list of newly generated id's to my application code (lets say PHP), and I would like the list to be in correlated order to what appears in the IN clause of the SELECT subquery. I'm thinking this would save me a lot of sequential INSERTs in my application code. Is that achievable?