php - mySQL "Rank in Highscore"-Query -


Hi is a worldwide codec,

I am working on a project where the user does something Things and profit points for this, to simplify this question, let's say that we have received 2 tables users and points .

  - Table user - Table numerals + --- ------------ + + ---------------- ------------- + | ID | Name | | ID | Points | User_id | + --------------- + + ----------------------------- + | 1 Tim | | 1 5 1 2 Tom | | 2 10 1 | Mark 3 | 3 5 1 4 Tina | | 4 12 2 5 Lutz | | 5 2 2 + --------------- + | 6 7 1 | 7 40 3 8 100 1 + ----------------------------- +  

Full Coordinate list I use the following question to get the

  SELECT u *, SUM (p.points) user by sumipoints as UIII Sum_points DESc  

First of all users with the highest score

  + ------------ ---- -------------- + | ID | Name | Sum_points | + ---------------------- + + | 1 Tim 127 | 3 March 40 | | 2 Tom 14 | | 4 Tina 0 | | 5 Lutz 0 | + ------------------------------ +  

Go back to the exact same question I want to show high ranking within the highest-ranked profile of a single user.

Can this be done only by an example, for example tom (id = 2) is given in position 3?

Thank you very much: -)

Ask this idea, "How many players Rank above @this_user ":

  Choose from count (*) + 1 (/ * List of all users * / SELECT SUM (p.points)) Users with Sum_points leave the user u .user_id = u.id GROUP BY u.id points on PO) x / * Just calculate those people with more zodiac points * / where sum_points & gt; (Digits_id = @this_user)  

To create 1-based results instead of (0-based

Edit
div>

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -