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

I think you need a group by statement:

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 回答