tags: mysql
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'ie_llyh.u.ChkPlanID'; this is incompatible with sql_mode=only_full_group_by
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'ie_llyh.u.ChkPlanID'; this is incompatible with sql_mode=only_full_group_by
Use group_concat in SQL to combine, if you are other group by reason, please find other solutions
After mysql5.7.5, the default opened online, so some SQL could not be executed normally, in fact, it is caused by our SQL irregular, because some of the data returned is uncertain, so this will appear mistake.
Code modified SQL
Rewriting involving the SQL section of Group_Concat
Original code
select a.cid
GROUP_CONCAT(c.name SEPARATOR ',') as allName
from class a
LEFT JOIN classUser b ON a.cid = b.cid
LEFT JOIN UserInfo c ON c.uid = b.uid
WHERE 1=1
After modification
select a.cid
b.name as allName
from class a
LEFT JOIN (
select GROUP_CONCAT(b.name SEPARATOR ',') as name , a.cid from classUser a
left join UserInfo b on a.uid = b.uid
group by a.cid
)b on a.cid = b.cid
where 1=1
Close ONLY_FULL_GROUP_BY, I am Linux environment, I just talk about Linux solution:
Linux login: mysql -u username -p, then enter the password, enter SQL: show variables like '% SQL_MODE';
File address is usually: /etc/my.cnf/eetc/mysql/my.cnf
Find the position of SQL-mode, remove online, then restart mysql
There is no SQL-MODE in my.cnf, you need to join:
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Service MySQL Restart, after restart, log in to Mysql, enter SQL: show variables like '% SQL_MODE'; if there is no online, it is already successful.
phenomenon: Performing sql SELECT COUNT (DISTINCT (colum1)), colum2, colum3 FROM table; error ERROR 1140 (42000): In aggregated query without GROUP BY ..... the reason: sql_mode default mysql opens up...
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column'szmz_zhbz_gov.b.cremation_time'; this is incompatible with sql_mode=only_full_group_by After reviewing ...
Preface Operating todaymysqlWhen querying data in the database, a prompt is encountered, the query fails, and the prompt message is as follows: When running this SQL statement, there is no problem: Bu...
Execute SQL query statement: Wrong [Err] 1140 - In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'cust_cx.c.card_type_name'; this is incompatible with s...
reason: 1. The official explanation of this mode: Only_Full_Group_by is a SQL_Mode provided by the MySQL database, guaranteed by this SQL_Mode, SQL statement "the highest value" legality che...
Shatter Brother Meng, I Hu Han San is coming back again (.. ∀ ·) ノ゙ ノ゙¯ ▽ ¯ *) § First, the problem description Today, I do SQL in the cow passenger net: the course of the...
There is no problem running on MySQL 5.5.27. The error of sql_mode=only_full_group_by is reported on MySQL 5.7.24: Error 1140: In aggregated query without GROUP BY, expression #1 of SELECT list contai...
Record an error in a mysql combination query plus grouping: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'tsbio.sl.id'; this is incompatible with sq...
Article Directory Problem description Problem traceability Solution 1 Solution 2 appendix: Problem description Here is a screenshot of the error: Translated: In an aggregation query without group BY, ...
A problem usually encountered when writing sql, record it There are three tables student (student table), teacher (teacher table), stu_teacher (student-teacher relationship table) The table structure ...