mysql使用group by 的時候報錯,錯誤信息如下:
1055:ER_WRONG_FIELD_WITH_GROUP: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated
column 'lbparking.tradingrecord.pname' which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by
解決步驟:
一、找到/etc/my.cnf
二、添加如下語句:sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
三、重新啟動MYSQL服務
service mysqld stop
service mysqld start
備注:上述解決操作在root賬號下進行