How can I get the pkey value for a newly inserted record (auto increment)?

I then insert one record into two tables. With the first insertion, I put the record in the main table, where the primary key value is generated. Now I need to put some fields of this record in another table, including the key value of the main table. How to do it?

+4
source share
1 answer

" SELECT LAST_INSERT_ID(); " will return the last generated auto-increment identifier.

+3
source

All Articles