Mysql排序和排名

时间:2012-02-18 07:52:42

标签: mysql rank

  

可能重复:
  Ranking joint positions in MySQL

我想通过排序获得用户的排名,我使用了以下mysql语句:

"SELECT u.uid,u.name,pn.value AS nick,(@rank:=@rank+1) as rank,CAST(pa.value AS SIGNED) AS solved,
    CAST(ps.value AS SIGNED) AS submissions FROM (SELECT @rank:=0) r,users u 
    LEFT JOIN profile_values pn ON u.uid=pn.uid AND pn.fid=1 
    LEFT JOIN profile_values pa ON u.uid=pa.uid AND pa.fid=4 
    LEFT JOIN profile_values ps ON u.uid=ps.uid AND ps.fid=5 
    WHERE status=1 ORDER BY solved desc,submissions"

它不起作用,它显示为uid。 谁能帮帮我?谢谢。

0 个答案:

没有答案