Home >Backend Development >PHP Tutorial >有一个积分表,积分从高往下排,怎么取出其中的一个用户的排名,积分

有一个积分表,积分从高往下排,怎么取出其中的一个用户的排名,积分

WBOY
WBOYOriginal
2016-06-13 12:17:481154browse

有一个积分表,积分从高往下排,如何取出其中的一个用户的排名,积分
sql语句是

<br />select a.username,(@rowNum:[email&#160;protected]+1) as c,a.integral as 积分<br />from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time<br />


我如何在这条sql语句的基础上,查询出用户的用户名,积分。

或者如何在php中获取一下?
------解决思路----------------------
SELECT * FORM <br />  (<br />    select a.username,(@rowNum:[email&#160;protected]+1) as c,a.integral as 积分<br />    from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time<br />  ) T<br /> WHERE username='XXX'


这种定义用户变量的写法还是很巧妙的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn