select count(1) as 排名 from 表名 where 分数字段 >= (select 分数字段 from 表名 where 姓名字段 = '用户名')
微擎写法
$uscore = pdo_fetch("SELECT score FROM ".tablename('game_list')." WHERE open_id = :open_id LIMIT 1",
array(':open_id' => $openid));
$total = pdo_fetch("SELECT count(1) as total FROM ".tablename('game_list')." WHERE score = :score LIMIT 1", array(':score' => $uscore['score']));
$hhl=round(($total['total']/$user_total)*100).'%';
SQL排名查询与微擎实现

本文介绍如何使用SQL进行排名查询,通过一个具体例子展示了如何根据分数字段为用户排名。此外,还提供了微擎环境下实现相同功能的PHP代码示例。
2306

被折叠的 条评论
为什么被折叠?



