MySQL 查询 ORDER BY 某些值先于其他值

发布于 2024-10-06 04:51:28 字数 278 浏览 0 评论 0原文

我正在开发一个游戏高分,其中完成时间存储在数据库中,但是如果您没有完成关卡但保存了高分,则完成时间为 0。

我正在尝试进行一个查询,其中列出了高分首先是最低完成时间,但我的简单 ORDER BY 当然是在开始时保留所有 0 完成时间!

有什么办法可以这样订购,但底部有 0。

我尝试过:

从高分中选择 ORDER BY 完成时间 > 0,completiontime = 0 ASC

有人有什么想法吗?

I am developing a game highscore where the time of completion is stored in a database, but if you don't complete the level but save your highscore, the completion time is 0.

I am trying to make a query which lists the highscore with the lowest completion time first, but my simple ORDER BY is sticking all of the 0 completion times at the start of course!

Is there any way I can order it like this, but have the 0's at the bottom.

I have tried:

SELECT FROM highscores ORDER BY completiontime > 0, completiontime = 0 ASC

Anyone have any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来日方长 2024-10-13 04:51:28
SELECT *
FROM highscores
ORDER BY completiontime = 0, completiontime
SELECT *
FROM highscores
ORDER BY completiontime = 0, completiontime
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文