Home >Backend Development >PHP Tutorial >有一个积分表,积分从高往下排,如何取出其中的一个用户的排名,积分
sql语句是
select a.username,(@rowNum:=@rowNum+1) as c,a.integral as 积分from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time
知道用户名么, 直接select 用户名,积分 from table where 用户名=用户名不就完事了么
??出表??。
SELECT * FORM ( select a.username,(@rowNum:=@rowNum+1) as c,a.integral as 积分 from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time ) T WHERE username='XXX'
SELECT * FORM ( select a.username,(@rowNum:=@rowNum+1) as c,a.integral as 积分 from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time ) T WHERE username='XXX'
SELECT * From ( select a.username,(@rowNum:=@rowNum+1) as c,a.integral as 积分 from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time ) T WHERE username=18511337033'
[SQL] SELECT * From ( select a.username,(@rowNum:=@rowNum+1) as c,a.integral as 积分 from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time ) T WHERE username=18511337033'[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 6
SELECT * FORM ( select a.username,(@rowNum:=@rowNum+1) as c,a.integral as 积分 from xs_user a,(Select (@rowNum :=0 ) ) b order by integral DESC,time ) T WHERE username='XXX'