- 1、本文档共7页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实目的:
掌握数据查询操作。
内容:1)2) 对各表中的数据进行不同条件的查询;
附录:语句清单
--sql 查询实验三代码
--------1
select student.*,sc.cno,sc.grade ----左外连接(显性连接)
from student left join sc on student.sno=sc.sno
/*
select student.*,sc.cno,sc.grade
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)
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
from student,sc,course -----------6
where student.sno=sc.sno and sc.cno=course.cno and course.cname=数据库
select sname
from student
where sageany(select sage
from student ----------7
where sdept=is
) and sdept is
select sname
from student
where sageall(select sage ------8
from student
where sdept=is)
and sdept is
select sname
from student ------------9
where sno in(select sno
from sc
group by sno
having COUNT(*)=7)
select * --------------10
from stu
文档评论(0)