943,799 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 1026
  • MySQL RSS
Jan 15th, 2008
0

Selecting the 3 latest entries in a table

Expand Post »
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.

Reputation Points: 18
Solved Threads: 2
Posting Whiz
Venom Rush is offline Offline
325 posts
since Oct 2007
Jan 15th, 2008
1

Re: Selecting the 3 latest entries in a table

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.

MySQL Syntax (Toggle Plain Text)
  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.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Jan 15th, 2008
0

Re: Selecting the 3 latest entries in a table

Thanks hollystyles. That worked perfectly
Reputation Points: 18
Solved Threads: 2
Posting Whiz
Venom Rush is offline Offline
325 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Pulling a portion of text from a MySQL table
Next Thread in MySQL Forum Timeline: SQL Update Script





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


Follow us on Twitter


© 2011 DaniWeb® LLC