MySQL按两个值排序 [英] MySQL order by two values

查看:110
本文介绍了MySQL按两个值排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之,我有一个各种各样的游戏,它的计分板显示了最终玩家的得分+他们花了多长时间才达到目标.我需要对MySQL结果进行排序,以使最快的时间中最高的分数排在首位,而最慢的时间中最低的分数排在最后,并且两者之间的所有内容都以相同的方式排名.但是我不知道该怎么做,这就是我的sql:

In short, I have a game of sorts, and the score board for it shows the score of the player at the end + how long they took to achieve it. I need to order my MySQL results so that the highest score in the fastest time is first and the lowest score with the slowest time is last, and everything in between is ranked in the same way. But I have no idea how I'd do that, here's my sql as it stands:

$sql1 = "SELECT * FROM boobmatch_highscores ORDER BY t_score DESC, time ASC";

任何帮助将不胜感激!

表中的数据:

Score       Time
23        00:04:32
23        00:04:31
25        00:02:32
16        00:06:32
35        00:04:32
2         00:01:17
-13       00:19:32
-3        00:07:27

推荐答案

您的查询应该可以正常工作.如果您有任何问题,只需将字段名称括在引号中,如下所示:

You query is supposed to work perfectly. If you have any issues just enclose the field names in quotes like so:

$sql1 = "SELECT * FROM boobmatch_highscores ORDER BY `t_score` DESC, `time` ASC";

猜测它是MySQL,否则不需要引号

Guessing it's MySQL, else the quotes won't be necessary

这篇关于MySQL按两个值排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆