MySql 统计排名
例子:
SET @ranking=0;
select *,@ranking:=@ranking+1 AS `ranking` from table ORDER BY `members` DESC;
先给用户变量 @ranking 赋值,mysql中用户变量以@开头,不用事先申明;
然后按照某字段排序,返回字段中增加 如下代码:
@ranki
例子:
SET @ranking=0;
select *,@ranking:=@ranking+1 AS `ranking` from table ORDER BY `members` DESC;
先给用户变量 @ranking 赋值,mysql中用户变量以@开头,不用事先申明;
然后按照某字段排序,返回字段中增加 如下代码:
@ranki