Thursday, November 22, 2018

MySQl, Error Number: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column



 MySQL version is  updatde from 5.5.36 to  5.7.24 in Ubuntu,
when I run MySQL script, the following message showed
"MySQl, Error Number: 1055  Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column"

As of MySQL 5.7.5, the default SQL mode includes ONLY_FULL_GROUP_BY which means when you are grouping rows and then selecting
something out of that groups,
you need to explicitly say which row should that selection be made from.
To turn off warning message
1. In file  /etc/mysql/my.cnf
 add
 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
 under
 [mysqld]
2. restart mysql server in
sudo service mysql restart Ubuntu


Reference:
https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql

1 comment: