MySQL 按限制排序困惑

标签 mysql

我今天遇到一个问题。这是我的工作表:

按“is_active” desc 从作业顺序中选择 id、名称、is_active

结果是:

enter image description here

但是当我想获取前 10 条记录时,我选择此:

从作业顺序中选择 id,name,is_active by `is_active` desc limit 10 offset 0

结果是

enter image description here

为什么id是14到5,应该是1到10。谁能告诉我为什么?

最佳答案

如果你想要更深的顺序,你必须明确要求它,否则结果将是不可预测的。因此,如果您也需要 id 订单,请添加它。

select id,name,is_active from jobs order by `is_active` desc, id asc limit 10 offset 0

关于MySQL 按限制排序困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42643300/

相关文章:

php - 单击单选按钮检索 mySQL 数据

mysql - 在 mysql 表中存储大自定义订单 ID 的方法

mysqldump : Got error: 1045: Access denied for user (using password: YES) when trying to connect server

mysql - 将 autoincrement id 字段加一

mysql - 如何在消息系统中列出对话

php - Laravel Voyager 属于多个关系显示 "No results found"

mysql - SQL 中的语法错误 SQL 状态 :42601

php - MYSQL数据库如何存储10000条记录?

mysql - Spring jpa hibernate mysql LocalDate 在坚持一天后关闭

php - 在 AJAX 中显示数据库数据的错误位置