Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    selecting the top 3 values from a database

    I'm wondering if this is even possible to do. I want to retrieve the top 3 scores from a database. I'm thinking MAX() but i cant wrap my head around the logic needed to do this. Is it possible to retrieve the top 3 values from a database? I'm sorry i dont have a snippet to post, i just really cant think of how to go about doing it. Any help would be very much appreciated

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    254
    Thanks
    1
    Thanked 63 Times in 63 Posts
    Should probably have posted this in the MySQL forum. In any case, I don't know what your DB looks like but just do a search and sort by desc order based on the scores and then use "Limit 3" to get the top 3 values.

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Limit 3, thank you! I knew i knew how to do this.. I just couldnt think of it... brainfart. Thanks again

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Also ORDER BY the row name to get the top 3 of a different row.
    Thanks.
    Rafiki.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Moving to MySQL.
    Also, LIMIT is a proprietary command. Selecting a limited count is dbms dependant.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Fou-Lu View Post
    Moving to MySQL.
    Also, LIMIT is a proprietary command. Selecting a limited count is dbms dependant.
    yes you are right,
    anyway, few solution to this problem:

    http://www.petefreitag.com/item/59.cfm

    best regards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •