[ msyql异常 ]


1. group by语句问题

问题:

SQL 错误 [1055] [42000]: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'pymysql.users.password' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

解决:

ONLY_FULL_GROUP_BY:
对于GROUP BY聚合操作,若select中的列没有在group by中出现,那么这句SQL是不合法的。

解决办法下my.cnf中添加以下几行

<pre>[mysqld]
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'