I don't think this is a duplicate of other rank statements as others do not seem to search the resulting table for a specific user
I have a table similar to:
| | column1 | column2 | column3 | column4 |
|-------|---------|---------|---------|---------|
| user1 | 100 | 49 | 3 | 1,980 |
| user2 | 7 | 5 | 51 | 500 |
| user3 | 1 | 65 | 44 | 307 |
| user4 | 6 | 66 | 445 | 397 |
| user5 | 4 | 67 | 442 | 437 |
I currently have this statement to sort the table:
$statement = "SELECT *
FROM tracker_players
ORDER BY (column1 + column2 + column3 + column4)
DESC";
The resulting table would be:
| | column1 | column2 | column3 | column4 |
|-------|---------|---------|---------|---------|
| user3 | 1 | 65 | 44 | 307 | // 417
| user2 | 7 | 5 | 51 | 500 | // 563
| user4 | 6 | 66 | 445 | 397 | // 914
| user5 | 4 | 67 | 442 | 437 | // 950
| user1 | 100 | 49 | 3 | 1,980 | // 2132
Once I've sorted the table as such, I want to be able to find out what position of the table userX
is in. i.e. user5
is in position 4 (or 3 if zero indexed).
Any help is appreciated. I can't seem to find any answers regarding this.
Thanks!