Sign in to follow this  

sql - how to get the first 10, or last 10...

This topic is 4596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

playing with mysql db. How do I get the 10 last post in a table, or how to get the 10 last sorted after date? Anyway ... I know this place is maybe not the best regarding db and sql ... anybody who know of a better forum/site?

Share this post


Link to post
Share on other sites
Use ORDER BY to get the table entries into the appropriate order, then use LIMIT to get the range of entries you want. You can use LIMIT X, Y where X is the offset into the recordset and Y is the number of entries you want returned. ORDER BY will be ascending by default, use ORDER BY [column] DESC to get them in descending order.

The mysql reference manual is the best first place to start. Just read up on the params that can be passed to the SELECT statement. ORDER BY and LIMIT are fairly basic params. google search "mysql forums" should give you a good list of forums specifically for mysql (I don't know if links to other dev oriented forums are allowed).

Share this post


Link to post
Share on other sites

This topic is 4596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this