나는 테이블과 같이 포맷 한 : 내가 달성하는 데 필요한 것은 제목에 대해 동일한 값을 가지고 모든 행을 발견하는 쿼리가결합 행
title source subject
Bill hits Fred newspaper 1/1/17 Bill
Bill hits Fred newspaper 1/1/17 Fred
Bill hits Fred newspaper 1/1/17 Violence
Mary likes pie newspaper 1/4/17 Mary
Mary likes pie newspaper 1/4/17 Pie
Mary likes pie newspaper 1/4/17 Apple
John dies newspaper 1/4/17 John
John dies newspaper 1/4/17 Obituary
...
원본 필드를 결합하고 제목 필드를 연결하는 하나의 레코드로 결합합니다. 즉, 위의 데이터에 대한 출력은 다음과 같습니다
title source subject
Bill hits Fred newspaper 1/1/17 Bill, Fred, Violence
Mary likes pie newspaper 1/4/17 Mary, Pie, Apple
John dies newspaper 1/4/17 John, Obituary
...
내가 GROUP_CONCAT 필요하지만, 모든 행에 걸쳐 제목과 소스를 비교하는 것은 정확한 구문의 확실하지 오전 그림.
select title, source, GROUP_CONCAT(subject) from mytable
WHERE
??? < < - 확실하지 않은 방법 단어 "제목 = 제목과 소스 = 소스"
솔루션 :
SELECT title, source, GROUP_CONCAT(subject) from mytable GROUP BY title, source
적절한 'GROUP BY'가 필요합니다. –