表结构如下
#查询排名
select id,name,point,(@rowno:=@rowno+1) as ranking from user_test,(select (@rowno:=0)) b order by point desc
#根据id查询某一个人的排名 (此处查询id为1的排名情况)
SELECT id,name,c.ranking from (selectid,name,point,(@rowno:=@rowno+1) as ranking from user_test,(select (@rowno:=0))b order by point desc) c where c.id=1;
#查询第一名的是哪位用 where ranking=1
select id,name,point,ranking from (selectid,name,point,(@rowno:=@rowno+1) as ranking from user_test,(select (@rowno:=0))b order by point desc) c where ranking=1;