ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate



ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'DBname.table.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by




平台: Mac OS X
报错: incompatible with sql_mode=only_full_group_by
版本: mysql  Ver 14.14 Distrib 5.7.16, for osx10.11 (x86_64) using  EditLine wrapper
参考: https://stackoverflow.com/questions/23921117/disable-only-full-group-by 
搜索: "version 5.7.11 running on Mac OS X"


解决办法
1)命令行登录mysql

2)执行语句:

SET @@GLOBAL.sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";

3)搞定



==================== 成功案例 ======================
mysql> select t.id from transactions t,transaction_info i where t.id=i.t_id   group by i.email order by i.email ASC;
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'DBname.table.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


mysql> SET @@GLOBAL.sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
Query OK, 0 rows affected (0.01 sec)


mysql> select t.id from transactions t,transaction_info i where t.id=i.t_id   group by i.email order by i.email ASC;
+-------+
| id    |
+-------+
|   436 |
|  7425 |
|  9372 |
+-------+





你可能感兴趣的:(Mysql)