作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两张 table 。 subjectTbl 和SubjectAllotTbl。
这是我的主题表
+------------+--------------+---------------------+--------------+--------+----------+
| Subject_Id | Subject_Code | Subject_Name | Periods_Week | Dep_Id | Semester |
+------------+--------------+---------------------+--------------+--------+----------+
| 1 | 6012 | Basic Electronics | 10 | 1 | 1 |
| 2 | 5412 | Computer Science | 7 | 1 | 3 |
| 3 | 1421 | Musical Science | 4 | 1 | 5 |
| 4 | 547 | Network Programming | 7 | 1 | 5 |
+------------+--------------+---------------------+--------------+--------+----------+
和SubjectAllotTbl
+------------+------------+
| Subject_Id | Teacher_Id |
+------------+------------+
| 1 | 1 |
| 2 | 3 |
| 3 | 2 |
+------------+------------+
我想要做的就是从表SubjectTbl中选择Subject_Name,其中相同的subject_id不应出现在SubjectAllotTbl中
我正在使用 MySql
最佳答案
select subject_name
from SubjectTbl
where subject_id not in ( select distinct subject_id from SubjectAllotTbl)
您可能不需要不同的,除非 subject_id 在不同的 Teacher_id 的SubjectAllotTbl 中重复
关于mysql - 如何从一个表中选择不应存在其他记录的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43020517/
我是一名优秀的程序员,十分优秀!