Database - Mysql

MySQL 5.7 이상 group by 오류 해결방법

빠빠담 2020. 6. 23. 11:54
반응형
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column '칼럼명' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

: group by 절에 포함되지 않은 칼럼(집계되지 않은 칼럼(nonaggregated column))을 select 절에서 뽑아올 경우, 어느 칼럼을 표시해야 할 지 몰라 exception 이 발생하는 현상이다. 

only_full_group_by 란?

mysql 5.7버전부터 sql_mode로 추가된 설정으로

집계되지 않은 칼럼을 select 절에서 뽑아오는 경우 exception을 낼지 exception 을 내지 않고 동작할지 결정하는 옵션이다.

 

 

 

/etc/mysql/mysql.conf.d/mysqld.cnf

 

[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

 

sudo service mysql restart

반응형

'Database - Mysql' 카테고리의 다른 글

Pivot table  (0) 2021.09.10
Transaction Isolation 확인 및 변경  (0) 2020.09.10
MySQL 기본 캐릭터 셋 설정하기  (0) 2020.06.16
MariaDB - timezone 설정  (0) 2020.06.02
MariaDB Galera Cluster  (0) 2020.06.02