从mysql表中获取最后一个插入的ID

How to get the last inserted ID of a table, even if the last x record(s) have been deleted?

x can be 1 and can be like 200

Assuming you're talking about auto incremented IDs:

SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'Table'

This will give you the next increment id. To get the last inserted id just minus 1.

Following query will give you the last id present in table

select id from table_name order by id desc limit 1;

Updated:

Then you should create table which contains two columns like table_name, last_id and you have to always update the last_id when you insert data into particular table. With this way you can fetch the Last id inserted to table.