数据库 查询所有没选修“0401010103”课程的学生学号及姓名

就是在这么一个数据库中,查询所有没选修“0401010103”课程的学生学号及姓名
“0401010103”是course_id

第1个回答  2014-07-03
select stud_id,name
from table
where course_id<>'0401010103'追问

不太对吧,如果有人选了包括那门课内的多门课,还是会被显示出来

追答

    先找出选了这门课程的stud_id

    从table里除去这些stud,剩下的就是没选修这门课程的

    select distinct stud_id,name

    from table

    where stud_id not in(

         select stud_id

         from table

             where course_id='0401010103'

       )

本回答被提问者采纳
相似回答