- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
SQL集锦
select cno,count(sno) from sc t group by cno having count(sno)1 select sno from sc t group by sno having count(*)1 select student.*,sc.* from student,sc where student.sno=sc.sno 若在等值连接中把目标列中重复的属性列去掉则为自然连接 select student.sno, sname, ssex, sage, sdept, cno, grade from student, sc where student.sno = sc.sno 连接操作不仅可以在两个表之间进行,也可以是一个表与其自己进行连接,称为自身连接。 查询一门课的间接先修课(即先修课的先修课) 在Course表中,只有每门课的直接先修课信息,而没有先修课的先修课。要得到这个信息,必须先对一门课找到其先修课,再按此先修课的课程号,找到它的先修课程。这就要讲Course表与其自身连接。 为此,要为Course表取两个别名,一个是first,一个是second select first.cno, second.cpno from course first, course second where first.cpno = second.cno; select student.sno, sname, ssex, sage, sdept, cno, grade from student left join sc on (student.sno = sc.sno); 复合条件连接:查询选修2号课程的且成绩在60分以上的所有学生 select student.sno, sname from student, sc where student.sno = sc.sno and sc.cno = 2 and sc.grade 60; 连接操作除了可以是两表连接,一个表与其自身连接外,还可以是两个以上的表进行连接,后者通常称为多表连接。 查询每个学生的学号、姓名、选修的课程名及成绩。 select student.sno, sname, cname, grade from student, sc, course where student.sno = sc.sno and sc.cno = course.cno 嵌套查询 select sname from student where sno in (select sno from sc where cno = 2) 带有In谓词的子查询 select sno, sname, sdept from student where sdept in (select sdept from student where sname = 刘晨)select sno, sname, sdept from student where sdept in (CS) 本例中的查询也可以用自身连接来完成: select s1.sno, s1.sname, s1.sdept from student s1, student s2 where s1.sdept = s2.sdept and s2.sname = 刘晨select sno, sname from student where sno in (select sno from sc where cno in (select cno from course where cname = 信息系统));select student.sno, sname from student, sc, course where student.sno = sc.sno and sc.cno = course.cno and course.cname = 信息系统;select sno, cno from sc x where grade =(select avg(grade) from sc y where y.sno = x.sno) 带有any(some)或all谓词的子查询 子查询返回单值时可以用比较运算符,但返回多值时要用any(有的系统用some)或all谓词修饰符。而是用any或all谓词时则必须同时使用比较运算符。其语义为: select sname, sage from student where sage any (select sage from student wher
文档评论(0)