User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 401,534 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,383 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 461 | Replies: 2 | Solved
Reply
Join Date: Oct 2007
Posts: 175
Reputation: Venom Rush is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Venom Rush's Avatar
Venom Rush Venom Rush is offline Offline
Junior Poster

Selecting the 3 latest entries in a table

  #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.

AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,165
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Selecting the 3 latest entries in a table

  #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.

SELECT someColumn 
FROM someTable 
ORDER BY someColumn DESC 
LIMIT 3
Last edited by hollystyles : Jan 15th, 2008 at 3:46 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Oct 2007
Posts: 175
Reputation: Venom Rush is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Venom Rush's Avatar
Venom Rush Venom Rush is offline Offline
Junior Poster

Re: Selecting the 3 latest entries in a table

  #3  
Jan 15th, 2008
Thanks hollystyles. That worked perfectly
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the MySQL Forum

All times are GMT -4. The time now is 3:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC