PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > A select for a game ranking page.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
A select for a game ranking page.

Réponse
 
LinkBack Outils de la discussion
Vieux 21/08/2007, 19h04   #1
Critters
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut A select for a game ranking page.

Hi
I have a table with:
player_name, top_score, number_of_plays

When I list them out I "ORDER BY top_score DESC, number_of_plays DESC,
player_name" to give some sort of order to the people with the same
scores.

What I would like to do is find out a players position without looping
through all the records, so my plan was to do a "SELECT count(*)" and
have "WHERE top_score > " the players top score.. however when there are
many scores the same I want to also do "WHERE number_of_plays > " the
players number of plays.

Doing "WHERE top_score > 1000 AND number_of_plays > 10" is no good as
some players have higher scores but lower plays but should be counted as
been higher ranked.

I don't want to loop through the scores, that's not very elegant. Also
creating a temp table where the scores are in order and then counting on
that would also be overkill?

I hope this makes sense and that there is a solution.
--
David Scott

  Réponse avec citation
Vieux 21/08/2007, 19h10   #2
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A select for a game ranking page.

Hi,

Critters wrote:
> Hi
> I have a table with:
> player_name, top_score, number_of_plays
>
> When I list them out I "ORDER BY top_score DESC, number_of_plays DESC,
> player_name" to give some sort of order to the people with the same
> scores.
>
> What I would like to do is find out a players position without looping
> through all the records, so my plan was to do a "SELECT count(*)" and
> have "WHERE top_score > " the players top score.. however when there are
> many scores the same I want to also do "WHERE number_of_plays > " the
> players number of plays.
>
> Doing "WHERE top_score > 1000 AND number_of_plays > 10" is no good as
> some players have higher scores but lower plays but should be counted as
> been higher ranked.
>
> I don't want to loop through the scores, that's not very elegant. Also
> creating a temp table where the scores are in order and then counting on
> that would also be overkill?
>
> I hope this makes sense and that there is a solution.


This is a common problem with ranked data. It seems to be exactly the
topic I wrote an O'Reilly article on:

http://www.oreillynet.com/pub/a/mysq...rank-data.html

Baron
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h33.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08866 seconds with 10 queries