从S(学号,姓名,年龄,生日)表和SC(学号,课程号,成绩)表中查询出没有选择课程号为1001的课程的所有学生的学号和姓名。
请问这个查询SQL语句该怎么写?
![](https://profile-avatar.csdnimg.cn/1f1dcbc7083642f09b577753451264df_mylove8671.jpg!4)
SQL查询没有选择某门课的所有学生的姓名学号
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- yicp123 2016-06-11 03:21关注
select s.number,s.name
from s where not exists (
select 1 from sc where sc.number=s.number and sc.course<>'1001');参考自:
EXISTS、IN与JOIN的用法区别 http://www.data.5helpyou.com/article307.html本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用