1
Tacks 212 天前
改成这个呢 `SELECT Id, Name, Order FROM test ORDER BY Order, Id;`
所有行的 Order 值都是 0 时,排序是不确定的。另外是你换个名字吧 order 这关键词被你当字段用。 |
2
a33291 OP @Tacks 是的,解决方案我们也是这样处理.只是好奇为啥不一致,我意思他排序算法跨平台不稳定而且不可配置好像
现在我们没有特别在意字段和关键字重复的情况,因为大部分时候都是 orm 自动生成的标准 sql,不会造成错误或者冲突 |
3
Tacks 211 天前
```
If multiple rows have identical values in the ORDER BY columns, the server is free to return those rows in any order, and may do so differently depending on the overall execution plan. In other words, the sort order of those rows is nondeterministic with respect to the nonordered columns. One factor that affects the execution plan is LIMIT, so an ORDER BY query with and without LIMIT may return rows in different orders. Consider this query, which is sorted by the category column but nondeterministic with respect to the id and rating columns: ``` 来自 https://dev.mysql.com/doc/refman/8.0/en/limit-optimization.html 简单来说 :如果在 ORDER BY 列中有多个行具有相同的值,则服务器可以自由以任何顺序返回这些行,并且根据整体执行计划的不同,返回值可能会有所不同。 |