Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php mysql_insert_id on multiple rows?

Tags:

sql

php

insert

Is it possible to get the auto incremented ids from a query which inserts multiple rows? eg:

INSERT INTO table (col1, col2) VALUES (1, 2), (3, 4), (5, 6);

Alteratively, is there a way to find the NEXT auto increment value WITHOUT inserting anything into the table?

Thanks

like image 912
Dan Avatar asked Nov 05 '09 09:11

Dan


1 Answers

As far as I know auto_increment does not fill gaps between ids and the operation is atomic. So you can assume that they will be in a row.

like image 100
Christian Strempfer Avatar answered Oct 07 '22 12:10

Christian Strempfer