mysql 分页数据错乱

 

 

最近在使用mysql 分页查询数据的时候发现返回的数据与预期的不一样,显示数据重复错乱。

官方文档 有这样一句话

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:        

说明当order by 列中有重复值的时候,mysql server 会看自己心情随机处理返回结果。

当使用mysql 进行分页查询出现数据不一致问题时候 可以看看order by 后面列数据是否有重复值

 

参考文献:数据库内核月报 - 2015 / 06

转载于:https://www.cnblogs.com/gsjlovenet/p/10533907.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值