Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- elasticsearch
- 제이쿼리
- 에러
- JavaScript
- Java
- tomcat
- Eclipse
- 쿼리
- 형변환
- HTML
- jQuery
- java 오류
- JSP
- eclipse utf8
- 데이터베이스
- db
- 자바
- Excel
- CSS
- 이클립스 설정
- 자바스크립트
- 한글 깨짐
- 자바 리스트
- MySQL
- 이클립스
- 엘라스틱서치
- spring 오류
- 엑셀
- eclipse 설정
- spring form
Archives
- Today
- Total
개발노트
[MySQL]this is incompatible with sql_mode=only_full_group_by 본문
반응형
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database.
Cause: java.sql.SQLSyntaxErrorException:
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column
'DB명.테이블 별칭.컬럼명' which is not functionally dependent on columns in GROUP BY
clause; this is incompatible with sql_mode=only_full_group_by
[원인]
이 오류는 MySQL의 ONLY_FULL_GROUP_BY 모드와 관련이 있다. 이 모드가 활성화되면, SELECT 목록에 있는 모든 비집계 열은 GROUP BY 절에 포함되어야 한다.
[해결 1] 쿼리 수정
SELECT 목록에 있는 모든 비집계 열을 GROUP BY 절에 추가
[해결 2] SQL 모드 변경
1. mysql 모드 확인
select @@sql_mode;
(ONLY_FULL_GROUP_BY가 있음을 확인)
2. 아래의 SQL문 실행
SET GLOBAL sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
SET @@sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
https://chamch-dev.tistory.com/3
https://info-lab.tistory.com/274
반응형