![]() |
mysql get last 10 records in a table
Does anybody know whether it is possible to get the last 10 records in a table, without having to load the whole contents of the table? If that's not possible then what other way would you recommend.
|
If it has some sort of sequential id or date associated with the record, you could do this:
SELECT * FROM mytable ORDER BY seq_id DESC LIMIT 10; Basically, this puts the last entries on top (via sorting in descending order), then limiting the results to 10 via LIMIT. |
Thanks a bunch IR that was exactly what I was looking for.
|
Glad you got it worked out man.
|
| All times are GMT -5. The time now is 12:19 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC