student:s
course:c
teacher:t
sc:sc1,sc2
先分别选语文的和数学的选修学生和分数
1、create view yuwen as
select sid,score from sc1,c where c.cid=sc1.cid and c.cname=‘语文'
2、create view shuxue as
select sid,score from sc2,c where c.cid=sc2.cid and c.cname=‘数学'
然后选出以上数据中同时选了两门课程且语文比数学成绩高的学生
3、create view student_id as
select yuwen.sid from yuwen,shuxue where yuwen.score>shuxue.score and yuwen.sid=shuxue.sid
选出语文成绩比数学成绩高的学生的sid:最后的结果语句就有了:
4、select s.sname from s,student_id where s.sid = student_id
也可以这样写:
1、create view yuwen as
select sname,sc1.sid,score from s,sc1,c where s.sid =sc1.sid and c.cid=sc1.cid and c.cname=‘语文'
2、create view shuxue as
select sname, sc2.sid,score from sc2,c where c.cid=sc2.cid and c.cname=‘数学'
3、select sname from (select yuwen.sname from yuwen,shuxue where yuwen.score>shuxue.score and yuwen.sid=shuxue.sid)
以上是一个详细的分析过程。写在一个句子里的话句子结构就有点复杂了。希望网友们补齐啊。
追问谢谢 你的分析 但是 我希望把这个过程写在一个 语句里,我使用表相关联 就出很大问题了