mysql排序分页乱的_Mysql 排序分页混乱
現(xiàn)象一
id=25這條數(shù)據(jù),出現(xiàn)在第一頁、第二頁。
數(shù)據(jù)特征: 排序字段,重復(fù)率極高,僅有2個(gè)值。
數(shù)據(jù)庫(kù)版本:
現(xiàn)象二
相同數(shù)據(jù),在以下數(shù)據(jù)庫(kù)版本,均排序分頁正常。
8.0.11
5.6.46
第一頁:
SELECT * FROM city order by FIELD(state,'ENABLE','DISABLE') LIMIT 0,10;
第二頁:
SELECT * FROM city order by FIELD(state,'ENABLE','DISABLE') LIMIT 10,10;
解決方案
關(guān)于現(xiàn)象一,官網(wǎng)給出以下解釋:
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.
當(dāng)有多個(gè)重復(fù)值的時(shí)候,mysql server返回的是任意順序。具體的順序依賴執(zhí)行計(jì)劃。
關(guān)于現(xiàn)象二,暫沒合理的解釋。
相同的數(shù)據(jù)庫(kù)版本,類似的重復(fù)數(shù)據(jù),分頁排序就是正常的。
相同的數(shù)據(jù),不同的數(shù)據(jù)庫(kù)版本,分頁排序也是正常的。
參考
總結(jié)
以上是生活随笔為你收集整理的mysql排序分页乱的_Mysql 排序分页混乱的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql5.6的安装步骤_MySQL5
- 下一篇: mysql交互式创建表_用mysql语句