If it is an auto_incremented value you would use mysql_insert_id()
(or its mysqli sibling) immediately after doing an insert to get the ID assigned to it.
If you wanted to get a non-auto incremented value you would need to SELECT the row with the highest value and sort by that value in descending order to do the job (assuming it is numeric or alphanumeric and increments sequentially):
SELECT id FROM tablename ORDER id DESC LIMIT 1
If it is a random ID than you would need to sort by date:
SELECT id FROM tablename ORDER datecol DESC LIMIT 1
If you don't have any other method of sorting these records you can get the last row in the table but there is no guarantee that record is the newest and thus you have no accuracy in your results.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…