我想列出Table A
中的所有项目,Table B
中已有的项目除外。
我似乎无法找到错误:
SELECT `topic_id`.st,`topic_title`.st
FROM `subject_topics` st
WHERE `topic_id`.st NOT EXIST (SELECT `topic_id`.sa
FROM `subject_assign` sa
WHERE `teacher_id`.sa='TEACHER')
我希望用户添加其他主题,但当然,他们不应该看到已添加的项目。
答案 0 :(得分:1)
表名和列名的顺序应该是相反的,如下所示:
SELECT st.`topic_id`, st.`topic_title`
FROM `subject_topics` st
WHERE st.`topic_id` NOT IN (
SELECT sa.`topic_id`
FROM `subject_assign` sa
WHERE sa.`teacher_id` = 'TEACHER'
)