我的表结构如下:排序分数然后通过时间
Name email score time
Hello [email protected] 100 15
Hello [email protected] 58 10
Test [email protected] 100 12
Stack [email protected] 90 20
Test [email protected] 50 40
使用select查询
$q="SELECT name, MAX(score) as score ,email FROM users GROUP BY email ORDER BY MAX(score) DESC LIMIT 10";
下面的结果产生。
Name email score time
Hello [email protected] 100 15
Test [email protected] 100 12
Stack [email protected] 90 20
我很困惑,如果两个用户有相同的分数,我想,基于最低时的结果进行排序,因为“测试”的用户在12秒内连得100,它应该是第一位的。
可这对您有所帮助http://stackoverflow.com/questions/514943/php-mysql-order-by-两列 –
推荐:http://stackoverflow.com/questions/5417980/mysql-sql-specific-item-to-be-first-and-then-to-sort-the-rest-of-the-items –