Today, the project changed its system, reinstalled the MySQL database, and the data was reported incorrectly when the function was executed.
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 're.name'; this is incompatible with sql_mode=only_full_group_by
Because there is no problem before changing the system, check the sql_mode=only_full_group_by on the Internet and find that the database itself is configured.
I am the database version is 5.7.24
Said this when I searched online.
Group by syntax:
Select selects the column in the group + aggregate function from table name group by grouped column
From the grammatical format, it is first grouped, and then the retrieved columns are determined. The retrieved columns can only be selected in the columns of the participating group.
Look at ONLY_FULL_GROUP_BY again: For the GROUP BY aggregate operation, if the column in the SELECT does not appear in the GROUP BY, then the SQL is not legal, because the column is not in the GROUP BY clause, that is, it is detected. The column must appear after group by or it will report an error, or this field will appear in the aggregate function.。
View the mysql version command:
select version();
View the sql_model parameter command:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
Find:
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
The first item turns on ONLY_FULL_GROUP_BY by default.
Solution:
1. Select only the columns that appear after the group by, or add an aggregate function to the column; (not recommended)
2. Command line input:
set @@GLOBAL.sql_mode='';
set sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Turn off ONLY_FULL_GROUP_BY by default!
This time select select
SELECT @@sql_mode;
SELECT @@GLOBAL.sql_mode;
Found that there is no ONLY_FULL_GROUP_BY, it feels OK. But if you restart the Mysql service, you will find that ONLY_FULL_GROUP_BY will still exist.
To completely solve this problem, you have to change the my.ini configuration (if you mysql does not have this file, change my-default.ini to my.ini, my version is changed to my.cnf)
Add under [mysqld] and [mysql]
sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Vi edit my.cnf
Add at the bottom
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
Restart MySQL and query again

Solution: modify the mysql configuration file The local server can modify this Add under [mysqld] Then restart service mysql restart ...
Specific error: [Err] 1055-Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally depende...
MySql reports an error sql_mode=only_full_group_by Prospect introduction problem solve Prospect introduction There is a long long ago project. As the purchased Alibaba Cloud database expired and no on...
Error scenario Today, I have a project that I just came down on my computer. When I log in to enter the home page, I reported a string of this is incompatible with sql_mode = only_full_group_by error,...
Report error message: Reporting error Mysql 5.7.5 and above function dependencies. If ONLY_FULL_GROUP_BY is enabled SQL Mode (By default), MySQL will refuse to select a list, the Having condition, or ...
Group by using a query in Mysql when the following error occurs: In the error was found, it has a problem sql_mode = only_full_group_by. Found by looking for the pattern must have a column correspondi...
The server is running normally, and an error occurs when the machine is running Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘mgl.db_mglmro_customer_c...
Edit the mysql configuration file (windows is my.ini, linux is my.cnf), add the following configuration under [mysqld]: Just restart the MySQL service...
environment Execute the query statement Report an error reason: MySQL 5.7.5 and above functions rely on detection function Solution After setting, if it does not take effect, you can exit and log in a...
1. Query mysql's mode: We need to remove the only_full_group_by mode 2. Set the mode Windows Open the my.ini file in the MySQL installation directory Add configuration Save after modification 3. Resta...