Previously (MySQL 5.7 and lower), GROUP BY sorted implicitly under certain conditions. In MySQL 8.0, that no longer occurs, so specifying ORDER BY NULL at the end to suppress implicit sorting (as was done previously) is no longer necessary. However, query results may differ from previous MySQL versions. To produce a given sort order, provide an ORDER BY clause.
google翻译
:以前(MySQL 5.7及更低版本),GROUP BY在某些条件下隐式排序。 在MySQL 8.0中,不再发生这种情况,因此不再需要在末尾指定ORDER BY NULL来抑制隐式排序(如前所述)。
但是,查询结果可能与以前的MySQL版本不同。 要产生给定的排序顺序,请提供ORDER BY子句
陈哈哈:“哦,这么看来开发老版本的同事是没用Order by,直接用了隐式排序。年轻人,不讲武德啊!!”
小王(小声):“哈哥,这模块之前好像是你负责的。”
陈哈哈(老脸一红):???
陈哈哈:“咳咳,这MySQL8.0团队不讲武德,给我挖坑!”
好了,接下来我们用测试数据演示一下
下面是表T测试数据,无序
mysql> SELECT pid,appName from T;
+--------+-------------------------+
| pid