If you want to get the id just after the insertion, use LAST_INSERT_ID()
:
SELECT LAST_INSERT_ID();
This will return the AUTO_INCREMENT
value of the last inserted element (in your current connection).
If you want to know which is the last inserted value in a determined table, use any of the queries provided in the other answers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…