Get all insert ids in a transaction
问题 I have two tables in a MySQL database: "messages" and "message_tags". The "messages" table has an auto increment column "message_id". In Java I want to add a batch of messages to the database using the java.sql package. I want to do this in one transaction to save queries. My SQL code should look something like this: START TRANSACTION INSERT INTO messages(`message`) VALUES ('message1'); INSERT INTO messages_tags(`message_id`, `tags`) VALUES (LAST_INSERT_ID(), 'tagfoo1'); INSERT INTO messages