有3张表
student(sno,sname,sage,ssex)
course(cno,cname,teacher)
sc(sno,cno,grade)
现要找出不学C2课程的学生姓名,我写了以下语句运行出现错误,请各位高手指正一下啊~并帮忙分析一下运行效率,有更好的方法赐教一下哦~学习ing....
select sname from student
where sno in
( (select sno from student)
except
(select sno from sc where cno in
(select cno from course where cname='c2')
)
)
student(sno,sname,sage,ssex)
course(cno,cname,teacher)
sc(sno,cno,grade)
现要找出不学C2课程的学生姓名,我写了以下语句运行出现错误,请各位高手指正一下啊~并帮忙分析一下运行效率,有更好的方法赐教一下哦~学习ing....
select sname from student
where sno in
( (select sno from student)
except
(select sno from sc where cno in
(select cno from course where cname='c2')
)
)
select sname from student
where sno in
( (select sno from student
where sno not in
(select sno from sc where cno in
(select cno from course where cname='c2')
)
)
s.*
from
student s
where
not exists(select 1 from cusrse co,sc where co.cno=sc.cno and co.cname='C2' and sc.sno=s.sno)
这个不是t-sql的关键字...
course(cno,cname,teacher)
sc(sno,cno,grade)现要找出不学C2课程的学生姓名(就是没有学c2的吧?)假设cno = 'c2'
select * from student where sno no in (select distinct sno from sc where cno = 'c2')假设sname = 'c2'
select * from student where sno no in (select distinct sno from sc , course where sc.cno = course.cno and course.cname = 'c2')
select * from student where sno not in (select distinct sno from sc where cno = 'c2')假设sname = 'c2'
select * from student where sno not in (select distinct sno from sc , course where sc.cno = course.cno and course.cname = 'c2')
sname
from
student
where
sno not in(select sc.sno from sc,course co where sc.cno=co.cno and co.cname='C2')