Reputation: 1
I have a "Top-20" System in my Webinterface where 20 players got listed and sorted by level. Now i want to show the guy, who is logged in, at the bottom of the table and display which entry he is. I have made it with photoshop to show how it should be:
My question is, how can i get the number of this specific entry? For the top 20 i have following query:
select username,spielerlevel,member,leader
from accounts
where adminlevel = 0
order by spielerlevel desc
limit 20
Thanks.
Upvotes: 0
Views: 80
Reputation: 3833
This can be a solution :
SELECT COUNT(*)+1
FROM accounts
WHERE adminlevel = 0
AND spierlerlevel < (
SELECT spierlerlevel
FROM accounts
WHERE username = "CURRENT USER NAME"
);
Upvotes: 0
Reputation: 74036
An approximation of his place in the list is given by this:
SELECT COUNT(1)
FROM accounts
WHERE adminlevel = 0
AND spielerlevel<[level]
(Replace [level]
with the respective user's level.)
The problem is just with many user having the same level. But this might be a problem in your example query as well.
Upvotes: 4