![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 317
Rep Power: 3
![]() |
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.
__________________
Quote:
|
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
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.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 317
Rep Power: 3
![]() |
Thanks a bunch IR that was exactly what I was looking for.
__________________
Quote:
|
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
Glad you got it worked out man.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL & Python | snipertomcat | Python | 2 | May 9th, 2007 12:49 PM |
| MySql Error | paulchwd | Other Web Development Languages | 8 | Feb 27th, 2007 1:37 PM |
| mysql table view require()or suggestions. | piercy | PHP | 15 | Apr 28th, 2006 6:29 AM |
| Tutorial - Using MySQL in C# | Darkhack | C# | 12 | Jan 17th, 2006 9:28 AM |
| Simple Perl / MySQL Problem.. pls help! | domquemo | Perl | 0 | Jan 11th, 2006 4:08 AM |