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

WBOY
Release: 2016-06-13 12:17:48
Original
1114 people have browsed it

有一个积分表,积分从高往下排,如何取出其中的一个用户的排名,积分
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 />
Copy after login


我如何在这条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'
Copy after login


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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!