全国博士后科研工作站:SQL数据库的查询问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 08:03:57
student表 有sno(学生学号) sname(学生姓名)score(学生成绩)
score 表 有vscore(学生成绩)sname(学生姓名)
现在想通过score表已知的vscore来查询成绩为80的学生学号~~~

现在分少,回答完的话我会追加的~~

select sno
from student
where score=
(select vscore
from score
where vscore=80)

select sno from student where score=(select vscore from score where vscore=80)

select 学生学号=student.sno,学生姓名=student.sname,学生成绩=score.vscore from student,score where student.sname=score.sname and score.vscore>='80'
当然,你也可以把表名象楼上一样定义成简单的方便书写.

select t1.sno,t1.sname,t1.score
from student t1,
score t2
where t1.sname=t2.sname
and t2.vscore>80
[稍微提醒一下]你的数据库设计有问题,通过学生姓名关联会有重复的情况。