The error is as follows:
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
column 'sports.a.id' which is not functionally dependent on columns in GROUP BY
clause; this is incompatible with sql_mode=only_full_group_by
The reason for the problem:
MySQL 5.7.5 and above functions depend on the detection function. If the ONLY_FULL_GROUP_BY SQL mode is enabled (by default), MySQL will reject select lists, HAVING conditions, or ORDER BY list queries that reference non-aggregate columns that are neither named in the GROUP BY clause, nor are they functionally dependent on them. (Before 5.7.5, MySQL did not detect functional dependencies, and ONLY_FULL_GROUP_BY was not enabled by default. For instructions on the behavior before 5.7.5, please refer to "MySQL 5.6 Reference Manual".)
Solution one:
Open navcat,
Query with sql:
select @@global.sql_mode
The queried value is:
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Remove ONLY_FULL_GROUP_BY and reset the value.
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’;
As shown below:
Write picture description here
Solution two:
Steps to success:
iterm open
sudo vim /etc/mysql/conf.d/mysql.cnf
Scroll to the bottom of the file to copy and paste
[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
To the bottom of the file
Save and exit input mode
sudo service mysql restart
Restart MySQL.
carry out!
As shown below: