Select last rows from MySQL table.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

Select last rows from MySQL table.

Post by lovelf »

How to select the last rows having a primary key that is auto incremented, how to select only the last x amount of records that were inserted into the table for example.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Select last rows from MySQL table.

Post by Celauran »

Code: Select all

SELECT foo FROM table_name ORDER BY id DESC LIMIT 10
Post Reply