Page 1 of 1

Auto-Increment, Last 3?

Posted: Fri Jul 26, 2002 10:04 am
by stickman373
Ihave a field called id in my mysql database and it's auto-incrementing, so I want to get the last 3 id values from the database. And some records could get deleted so it isn't always going to be records like 6,5,4. Say I deleted 4 then the the last 3 rows would be 6,5,3. How do i find each of the last 3 id values please

Posted: Fri Jul 26, 2002 10:25 am
by RandomEngy
This query will return the id's of the most recent 3 entries.

SELECT id FROM tablename ORDER BY id DESC LIMIT 0, 3