0

このクエリでは、DISTINCTキーワードが機能していません。件名テーブルから重複する件名を表示します。どこで間違いを犯したか誰か教えてもらえますか?

SELECT DISTINCT
  tutor_category_subject.subject_id,
  GROUP_CONCAT(subject.subjects SEPARATOR ', ') AS subjects  
FROM       tutor_category_subject
INNER JOIN subject ON tutor_category_subject.subject_id = subject.subject_id
WHERE tutor_category_subject.tutor_id = 3;
4

1 に答える 1

1

groupbyステートメントが必要だと思います。

SELECT tutor_category_subject.subject_id,
       GROUP_CONCAT(subject.subjects SEPARATOR ', ') AS subjects  
FROM tutor_category_subject INNER JOIN
     subject
     ON tutor_category_subject.subject_id = subject.subject_id
WHERE tutor_category_subject.tutor_id = 3
group by tutor_category_subject.subject_id
于 2012-07-22T13:31:13.923 に答える