Welcome to Dream.In.Code
Become an Expert!

Join 149,494 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,359 people online right now. Registration is fast and FREE... Join Now!




MySQL and in-game ranking systems

 
Reply to this topicStart new topic

MySQL and in-game ranking systems

girasquid
25 Mar, 2007 - 04:48 PM
Post #1

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
Hello, all.

I've been working on a browsergame lately where users are ranked against one another. In order to determine the order that users are ranked in, this query is used:
CODE

SELECT username FROM user_stats ORDER BY army_size DESC

On a user's overview page, they should be able to see what rank they are. However, I can't for the life of me figure out how to figure out their rank. Is there a way to determine what rank a specific user ID would have, in the context of the query above?

Thanks,
Girasquid
User is offlineProfile CardPM
+Quote Post

girasquid
RE: MySQL And In-game Ranking Systems
25 Mar, 2007 - 08:06 PM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
I managed to figure out a solution to this, in one of those "I feel stupid moments". Here's the query:
CODE

SELECT COUNT(*)+1 FROM user_stats WHERE army_size > ?

Where ? is the player's army size.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 05:55PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month