Selecting the 3 latest entries in a table

Thread Solved

Join Date: Oct 2007
Posts: 260
Reputation: Venom Rush is an unknown quantity at this point 
Solved Threads: 2
Venom Rush's Avatar
Venom Rush Venom Rush is offline Offline
Posting Whiz in Training

Selecting the 3 latest entries in a table

 
0
  #1
Jan 15th, 2008
Hi guys and gals

Just curious to know if it's possible to select the 3 latest entries in a table. Would be an added bonus to my project.

Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Selecting the 3 latest entries in a table

 
1
  #2
Jan 15th, 2008
Use the LIMIT keyword (Similar to TOP in MSSQL) If you use ORDER BY to order the results descending, so that the latest records will be at the top of the result set. Then use LIMIT to get just the first three of those records.

  1. SELECT someColumn
  2. FROM someTable
  3. ORDER BY someColumn DESC
  4. LIMIT 3
Last edited by hollystyles; Jan 15th, 2008 at 4:46 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 260
Reputation: Venom Rush is an unknown quantity at this point 
Solved Threads: 2
Venom Rush's Avatar
Venom Rush Venom Rush is offline Offline
Posting Whiz in Training

Re: Selecting the 3 latest entries in a table

 
0
  #3
Jan 15th, 2008
Thanks hollystyles. That worked perfectly
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the MySQL Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC