Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Mysql League Positions

  • 05-12-2006 12:44pm
    #1
    Registered Users, Registered Users 2 Posts: 1,086 ✭✭✭


    I'm creating a fantasy league website. I need to display the position of members when they log in.

    In my overall table I get all members and order them by the amount of points they have. Then in my php code I print their position as the order in which they appear. i.e. Row 0 = 1st position, Row 1 = 2nd Position etc

    When I want to just display a single persons position I do not want to have to call the same query as my overall table, return the whole resultset and go through that until I reach the member id which I can then say their position is row + 1.


    Is there a mysql function query where I can find where a row ranks in a table?


Comments

  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    Unfortunately, mySQL doesn't support rownum, otherwise you could have done this:
    SELECT 
      myCol
    FROM 
      (select rownum as MyCol,
      UserID from myLeagueTable)
    WHERE 
      userID = 'TheUserID'
    

    but if you google for mySQL & rownum you may be able to get a workaround.

    This will return the number of the row, but I don't know how to nest this as I have done above:
    SELECT @rownum:=@rownum+1 rownum, t.*
    FROM (SELECT @rownum:=0) r, mytable t;
    


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    not sure how to do it on MySql
    but i think you are missing something on your website
    most fantasy football sites let you see your position for each week
    so you prob need another table with the week number, team , team score and team position

    of course that way when you want an idividual team position is very easy


Advertisement