zxzm.net
当前位置:首页 >> mysql 排名 >>

mysql 排名

select (select count(*) from `table` where k.socre

SELECT B.NAME, B.SCORES, (SELECT COUNT(1) + 1 FROM 分数表 A WHERE A.SCORES > B.SCORES) PM FROM 分数表 B ORDER BY PM;

select a.姓名,(@rowNum:=@rowNum+1) as 名次from 表名 a,(Select (@rowNum :=0) ) border by 积分 DESC,注册时间

select s.id,s.name,s.score,s.kemu, (select count(1) + 1 from score sc where sc.kemu = s.kemu and sc.score > s.score) as mingci /*分数相同,名次并列*/ from score s where 1 = 1 /* and s.name = 'uOXd' and s.kemu in ('R','L','W','S'...

因为mysql里没有top方法,使用top会报语法的错误, mysql提供了limit方法,可以达到同样的效果。 select?*?from?table?order?by?id?desc?limit?10;

这个如果想要性能的话,就用下面的sql语句实现: select orderNo from (select (@rowNum:=@rowNum+1) orderNo , userid ,pid from TABLE,(Select (@rowNum :=0) ) b )t where t.userid=2694 然后php获得这条结果数组,取第一个元素即是排序 如果...

select t1.*,(select count(*)+1 from (select cm_id,sum(`count`) counts from 表名 group by cm_id) t2 where t1.counts

select * from (select Student.S#,Sname,Sage,Ssex,SC.C#,score,Cname from SC inner join Student on SC.S#=Student.S# inner join Course on Course.C#=SC.C#) as t where exists( select count(1) from t as d where C#=d.C# and score < d....

mysql 没有top的用法。取而代之的是limit 语法为:limit m,n 省略n就可以得到你要的效果了。 select * from table1 limit 10

set @mycnt = 0; SELECT * FROM ( SELECT id,score,(@mycnt := @mycnt + 1) as rank FROM tab t ORDER BY score desc ) a ORDER BY id

网站首页 | 网站地图
All rights reserved Powered by www.zxzm.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com