Execution statement:
select de.dept_no, count(s.salary) from salaries s left join dept_emp de on s.emp_no = de.emp_no;
Complete error message:
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'demos.de.dept_no'; this is incompatible with sql_mode=only_full_group_by
After searching for information, the problem is that there will be this error in Mysql version 5.7 and above, just change it sql_mode
.
# 查看sql_mode
select version(), @@sql_mode;
# 更改sql_mode
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
After changing the settings, the problem is solved.
Reference blog:
https://cloud.tencent.com/developer/article/1404739