表:student(sno,sname,ssex,sbirthday,class)

表:student(sno,sname,ssex,sbirthday,class)
score(sno,cno,degree)
course(cno,cname,tno)
teacher(tno,tname,tsex,tbirthday,prof,depart)
题:查询和“小王”不同班并同个教师的同学Sname.
hello88118 1年前 已收到1个回答 举报

lsliiii 幼苗

共回答了25个问题采纳率:92% 举报

select sname from student
where sno in (
select sno from student,score,course,teacher
where student.sno=score.sno
and course.cno=score.cno
and teacher.tno=course.tno
and student.sname='小王'
and student.class not in(select class from student where sname='小王')
)

1年前 追问

10

hello88118 举报

服务器: 消息 209,级别 16,状态 1,行 1
列名 'SNO' 不明确。。。

举报 lsliiii

select sname from student
where sno in (
select student.sno from student,score,course,teacher //这里的忘记加了
where student.sno=score.sno
and course.cno=score.cno
and teacher.tno=course.tno
and teacher.tno in (
select teacher.tno from student,score,course,teacher
where student.sno=score.sno
and course.cno=score.cno
and teacher.tno=course.tno
and student.sname='小王'
)
and student.class not in(select class from student where sname='小王')
)
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.039 s. - webmaster@yulucn.com