在此查询中,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;
答案 0 :(得分:1)
我认为你需要一个分组声明:
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