SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: second highest

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    second highest

    I know its poosible to select the highest number in a coullum using

    SELECT MAX(collum) AS collum from table

    Is there a function or something similar to select the sencond highest? third? ect....?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    //Gives you the highest
    SELECT * from tablename ORDER by column DESC LIMIT 1;

    //Gives you the second highest
    SELECT * from tablename ORDER by column DESC LIMIT 1, 1;

    //Gives you the third highest
    SELECT * from tablename ORDER by column DESC LIMIT 2, 1;
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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