Is there a way in mySQL (or other databases for that matter) to retrieve an auto-incrementing value when performing an INSERT statement? e.g. I have a table such as the following:
Person
--------------
BIGINT PersonID (PK, Auto-increment)
VARCHAR(20) FirstName
VARCHAR(30) LastName
CHAR(1) Gender
VARCHAR(50) Email
Typically I'd simply do an insert like this:
INSERT INTO Person (FirstName, LastName, Gender, Email) VALUES ('Benny', 'Hill', 'M', 'benny@hill.com');
However, there's no way of retrieving the new PK at the same time. Is there perhaps a way of locking the table to grab the most recent insert at the same time? Or even better, a way to do this without explicitly locking the table?