mysql 为什么加了排序字段后不会自动按ID升序排序?

奇怪的现象:

SELECT store_id,store_name,is_update_virtual,store_state,store_sort FROM `sto_store` as `store` WHERE `store`.store_state = '1' order by store_sort asc   limit 0,20;

得出的结果不会优先使用store_sort 字段排序然后默认使用ID升序排序而是无规律的。导致得出的分页结果会重复。

SELECT store_id,store_name,is_update_virtual,store_state,store_sort FROM `sto_store` as `store` WHERE `store`.store_state = '1' order by store_sort asc,store_id asc   limit 0,20;

得出的分页结果是正常的。


原文地址:https://www.cnblogs.com/linewman/p/9918806.html