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?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…