sql数据库系统原理上机实验(综合版)(4)

2019-04-17 15:16

/* -----------------20第二种解法 select cname,COUNT(student.sno),AVG(grade) from student,sc,course

where student.sno=sc.sno and sc.cno=course.cno group by sc.cno,cname */

select * ------为什么这里查询不到结果 from course -------------21 where cpno is null

--sql 查询实验三代码

--------1

select student.*,sc.cno,sc.grade ----左外连接(显性连接) from student left join sc on student.sno=sc.sno /*

select student.*,sc.cno,sc.grade

16

from student inner join sc ----内连接法(显性连接) on student.sno=sc.sno */ /*

select student.*,sc.cno,sc.grade ----------隐性连接 from student,sc

where student.sno=sc.sno */

select first.cname,first.cpno,second.cno from course first,course second ----------2 where first.cpno=second.cno

select student.*,sc.* ---------------3 from student right join sc on student.sno=sc.sno

select student.sno,sname from student,sc,(select student.sno

from student,sc -----4 导出表的使用 where sc.sno=student.sno and cno='2' group by student.sno)as result(sno)

17

where student.sno=sc.sno and cno='3' group by student.sno,student.sname

select student.sno,sname

from student,sc as x --------4法二

where student.sno=x.sno and cno='2' and exists(select student.sno from student,sc as y

where cno='3' and exists(select * from student,sc as z

where z.sno=y.sno and z.sno=x.sno))

select student.sno,sname

from student,sc as x,sc as y ------4法三

where student.sno=x.sno and x.sno=y.sno and x.cno='2' and y.cno='3' select *

from student as x,student y --------5 where x.sname='刘晨' and x.sage=y.sage

select sname,sage

18

from student,sc,course -----------6 where

student.sno=sc.sno

and

sc.cno=course.cno

course.cname='数据库'

select sname from student

where sage

from student ----------7 where sdept='is' ) and sdept< >'is' select sname from student

where sage'is'

select sname

from student ------------9 where sno in(select sno from sc

and

19

group by sno

having COUNT(*)=7)

select * --------------10 from student

where sdept='is' and ssex='男'

select distinct student.sname -------------11 from student,sc

where sc.cno='1' except(select student.sname from student,sc where sc.cno='2') select cno

from sc ---------------------12 where sc.sno not in(select sno from student

where student.sname='李丽')

select AVG(sage) --------------------------13 from student,sc

where student.sno=sc.sno and cno='3'

20


sql数据库系统原理上机实验(综合版)(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2017年10月自考02120数据库及其应用试题及答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: