Let's say I am doing a MySQL INSERT
into one of my tables and the table has the column item_id
which is set to autoincrement
and primary key
.
How do I get the query to output the value of the newly generated primary key item_id
in the same query?
Currently I am running a second query to retrieve the id but this hardly seems like good practice considering this might produce the wrong result...
If this is not possible then what is the best practice to ensure I retrieve the correct id?
INSERT
query like that; why do you think it might produce the wrong result? – Explosion Pills