rank -
BaubaS - 12.03.2012
How to get player rank by for example money? For e.g there is 4 registered players: Me, player a, player b, player c. So, I want to know, in which place I am by money. Any suggestions?
Re: query -
BaubaS - 12.03.2012
soz, bump
Re: query -
Vince - 12.03.2012
PHP код:
SELECT COUNT(`name`) FROM `table` WHERE `money` < '%d';
Where %d is of course formatted with the players money. Not sure if it works.
Re: query -
MP2 - 12.03.2012
Not 100% sure what you're asking, but I assume this will help:
http://thinkdiff.net/mysql/how-to-ge...g-mysql-query/
Re: query -
BaubaS - 12.03.2012
Quote:
Originally Posted by MP2
|
Can anyone rewrite that code in PAWN? I think this is what I need, but the problem is that I dont understand PHP ://
Re: query -
BaubaS - 13.03.2012
For those who doesnt understand, I've made this topic more simple
Re: query -
TTJJ - 13.03.2012
Hi BaubaS,
When you say by money, I assume you mean you want to determine which player has X amount of money? If so you can use the following:
PHP код:
SELECT `column_name` FROM `table_name` WHERE money = '%d'
"%d" obviously being the amount of money, however if you are looking to see how many people have X amount of money, you would do the following:
PHP код:
SELECT COUNT(id) AS count FROM `table_name` GROUP BY money
Hope it helped.
Cheers,
TJ
EDIT: I think I actually understand a little better, you want to rank the players in order of money. In which case you would use the following:
PHP код:
SELECT name FROM `table_name` ORDER BY money DESC
This query would return a list of players in order of money from highest to lowest, the first result would be the player who currently has the most amount of money.
Re: query -
BaubaS - 13.03.2012
Quote:
Originally Posted by TTJJ
Hi BaubaS,
When you say by money, I assume you mean you want to determine which player has X amount of money? If so you can use the following:
PHP код:
SELECT `column_name` FROM `table_name` WHERE money = '%d'
"%d" obviously being the amount of money, however if you are looking to see how many people have X amount of money, you would do the following:
PHP код:
SELECT COUNT(id) AS count FROM `table_name` GROUP BY money
Hope it helped.
Cheers,
TJ
EDIT: I think I actually understand a little better, you want to rank the players in order of money. In which case you would use the following:
PHP код:
SELECT name FROM `table_name` ORDER BY money DESC
This query would return a list of players in order of money from highest to lowest, the first result would be the player who currently has the most amount of money.
|
Thanks for trying to help, but you haven't got the point. I want to get certain player (for example - player a) rank for example by money.
Quote:
EDIT: I think I actually understand a little better, you want to rank the players in order of money. In which case you would use the following:
PHP код:
SELECT name FROM `table_name` ORDER BY money DESC
|
This is very same what do I need ,but I need to get certain player rank, not to rank all players.
Re: query -
TTJJ - 13.03.2012
Hi Again BaubaS,
I have been looking around and stumbled across a different method. However this method assumes that you already have the players money. So for instance the user is online and wants to know their money rank, you know they have 1000. You would then exectue the following query:
PHP код:
SELECT COUNT(id) AS count FROM `table_name` WHERE money > '1000'
The row "count" would then be the number of users who have more money than the user who initiated the query, giving your user their place in the table. So for instance
Player A has 1000
Player B has 2000
Player C has 3000
If player A initiates this query then it will look for all users who have more money than him and return the number of results it finds, in this case 2. Therefore player A's position is 3.
Hope that made sense.
Cheers,
TJ
Re: query -
BaubaS - 13.03.2012
Quote:
Originally Posted by TTJJ
Hi Again BaubaS,
I have been looking around and stumbled across a different method. However this method assumes that you already have the players money. So for instance the user is online and wants to know their money rank, you know they have 1000. You would then exectue the following query:
PHP код:
SELECT COUNT(id) AS count FROM `table_name` WHERE money > '1000'
The row "count" would then be the number of users who have more money than the user who initiated the query, giving your user their place in the table. So for instance
Player A has 1000
Player B has 2000
Player C has 3000
If player A initiates this query then it will look for all users who have more money than him and return the number of results it finds, in this case 2. Therefore player A's position is 3.
Hope that made sense.
Cheers,
TJ
|
Thanks again, but whats then if Player A haves 1000, but other players have 900, 800, 700, 600, 500. They will be not included in the query, right? :S Or, I should just do
SELECT COUNT(id) AS count FROM `table_name` WHERE money > '0'