This question already has an answer here:
I have a table in database which has a primary key called id. Now i want to display the most recently added 2 records into the table.
</div>
This wil definitely work,
SELECT * FROM table_name ORDER BY id DESC,LIMIT 2.
Assuming id is some sort of auto-incrementing integer value then the following will work
SELECT * FROM table ORDER BY id DESC LIMIT 2;
If you want just the last inserted record id (again assuming the insert generates an autoincrement id) there is also LAST_INSERT_ID. But beware this is global and will return last inserted id database-wide so it is not often used in SELECTS but rather as an OUT paramer in a routine to return the id of the just-inserted row.
SELECT LAST_INSERT_ID();
Try,
SELECT * FROM table
ORDER BY id DESC LIMIT 0, 2;