mysql ERROR 1140 (42000): In aggregated query without GROUP BY
mysql和oracle不一样mysql可以通过设置sql_mode可以支持下边写法
mysql> SET sql_mode = ''; Query OK, 0 rows affected (0.00 sec)
mysql> SELECT owner, COUNT(*) FROM pet; +--------+----------+ | owner | COUNT(*) | +--------+----------+ | Harold | 8 | +--------+----------+ 1 row in set (0.00 sec)
如果sql_mode设置这种就报错了
mysql> SET sql_mode = 'ONLY_FULL_GROUP_BY'; Query OK, 0 rows affected (0.00 sec) mysql> SELECT owner, COUNT(*) FROM pet; ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'menagerie.pet.owner'; this is incompatible with sql_mode=only_full_group_by
本文来自博客园,作者:蚌壳里夜有多长,转载请注明原文链接:https://www.cnblogs.com/dbahrz/p/17216658.html

浙公网安备 33010602011771号