我正在制作这个游戏排行榜,并试图在这个排行榜中获得特定用户的位置。我试过这个但没有运气:
SELECT SUM(points) as points
FROM publicpoints
GROUP BY fk_player_id
WHERE points > (SELECT SUM(points) as points
FROM publicpoints
WHERE fk_player_id = $playerid)
我该怎么办?
- - - - - - - - 编辑 - - - - - - - - -
我也试过这样,但仍然没有运气,但也许这澄清了我试图完成的事情:
$sql = mysql_query("SELECT SUM(points) mypoints FROM ".$prefix."_publicpoints WHERE fk_player_id=$playerid");
$row = mysql_fetch_assoc($sql);
$mypoints = $row['mypoints'];
$sql = mysql_query("SELECT SUM(points) as points FROM ".$prefix."_publicpoints
WHERE points < $mypoints
GROUP BY fk_player_id");
$row = mysql_fetch_assoc($sql);
$rank = mysql_num_rows($sql);
if(!empty($mypoints)){
$rank = $row['rank']+1;
} else {
$rank = 0;
}