MySQL高分 - 用户的个人排名:重复的条目导致错误的值

I'm currently creating a page in PHP that will display a user and their ranks in my site's highscores.

However, I have one field that is different from the rest and isn't functioning as intended.

Here is my table:

-- ----------------------------
--  Table structure for `playerstats`
-- ----------------------------
DROP TABLE IF EXISTS `playerstats`;
CREATE TABLE `playerstats` (
  `uid` int(11) NOT NULL DEFAULT '0',
  `gamelevel` int(11) NOT NULL DEFAULT '0',
  `overall` int(11) NOT NULL DEFAULT '0',
  `overallxp` bigint(20) NOT NULL DEFAULT '0',
  KEY `uid` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

...and some example data:

INSERT INTO `playerstats` VALUES ('14950', '123', '1495', '129825211')
INSERT INTO `playerstats` VALUES ('28967', '124', '1495', '127168799')
INSERT INTO `playerstats` VALUES ('95848', '121', '1495', '108481173')

Here is my query:

SELECT count(*) + 1 FROM (SELECT uid, overall, overallxp, gamelevel FROM playerstats GROUP BY playerstats.uid) AS x WHERE overall > (SELECT overall FROM playerstats WHERE uid = ". $userid .")"

...and $userid is:

$userid = (int) $_GET['searched'];

Now, when I navigate to the personal highscores of userid14950, it displays the correct overall ranking for that user because they are the person with the highest overallxp for their overall. However, when I visit the personal highscores of userid28967 or userid95848, their overall rank is the same as userid14950 for some reason (most likely because I don't account for users with the same overall result).

My question is: how would I go about making it so if two (or more) users share the same overall, they have their correct rank displayed, and not a duplicate one?

So that's about it.
Any help is very much appreciated :)

Thanks,
Mark

try this:

SET @rank = 0;
SELECT rank FROM (
    SELECT @rank:=@rank + 1 AS rank, uid FROM playerstats ORDER BY overall DESC, 
    overallxp  DESC
) as tmp WHERE uid = 14950

the avove query will return the rank for user14950

This query will list all the users and their ranks

SET @rank=0;
SELECT rank, uid, overall, overallxp FROM (
SELECT @rank:=@rank + 1 AS rank, uid, overall, overallxp FROM playerstats ORDER BY overall DESC, overallxp DESC
) as tmp