Last values in mysql

Reply

Join Date: Jun 2005
Posts: 44
Reputation: namit is an unknown quantity at this point 
Solved Threads: 0
namit namit is offline Offline
Light Poster

Last values in mysql

 
0
  #1
Nov 28th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 802
Reputation: Phaelax is on a distinguished road 
Solved Threads: 40
Phaelax Phaelax is offline Offline
Practically a Posting Shark

Re: Last values in mysql

 
0
  #2
Nov 29th, 2005
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)
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: Last values in mysql

 
0
  #3
Dec 26th, 2005
you might also want to put LIMIT 5 on there at the very end to just retrieve the last 5 results
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3245 | Replies: 2
Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC