944,008 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 5285
  • MySQL RSS
Nov 28th, 2005
0

Last values in mysql

Expand Post »
I have a databse in mysql and am looking to select the last 5 values in the database and there contence. How would i do this.

Will be using php to do this.

Thanks

There is an incramenting variable called Id and could use that if possible.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
namit is offline Offline
44 posts
since Jun 2005
Nov 29th, 2005
0

Re: Last values in mysql

I think this will work. I'm not positive if TOP is in MySQL.

SELECT TOP 5 *
FROM table
ORDER BY id DESC

(assuming 'id' is the primary key in the table)
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004
Dec 26th, 2005
0

Re: Last values in mysql

you might also want to put LIMIT 5 on there at the very end to just retrieve the last 5 results
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: index checking?
Next Thread in MySQL Forum Timeline: MySql database Synchronization





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC