MySQL按两个值排序

编程入门 行业动态 更新时间:2024-10-27 08:29:21
本文介绍了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按两个值排序

本文发布于:2023-11-08 13:23:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569485.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!