对于教学数据库的三个基本表:      学生 S(S#,SNAME,AGE,SEX)      学习 SC(S#,C#,GRADE)

对于教学数据库的三个基本表:      学生 S(S#,SNAME,AGE,SEX)      学习 SC(S#,C#,GRADE),第1张

怎么出完题目就不见人了,也不来确认??

1,select s,sname from S where age<22 and sex='女'

2,select count(*) from SC

3,select sname,age where sex='男' and age>(select max(age) from S where sex='女')

4,insert into S values('S9','WU',18)

5,delete from SC where grade is null

6,update SC set grade=grade*1.05 where c='C4' and grade<=75

update SC set grade=grade*1.04 where c='C4' and grade>75

7,select sname from S where sex='女' and sno in(

select sno from SC where c in(

select c from C where teacher='LIU老师'))

8,select c,cname from C where c in(

select c from SC SC1 where exists(

select * from SC SC2 where SC2.c=SC1.c and SC2.s in(

select S.s from S)))

9,select s,sname from S where sex='男' and age>23

10,select s from S where exists(

select * from SC where SC.s=S.s and c in(

select c from C where teacher='LIU老师'))

11,select SC1.s

from (select SC.s,count(*) countnum from SC group by SC.s) SC1

where SC1.countnum>=2

12,select c,avg(grade) from SC

where c in(select C.c from C where teacher='LIU老师')

group by SC.c

13,select sname,age from S where sname like 'WANG%'

14,insert into STUDENT

select S.s,S.sname,S.sex from S where not exists(

select * from SC where S.s=SC.s and grade<80)

15,select s,c from SC where grade is null

16,select S1.sname,S1.age from S S1 where S1.sex='男' and S1.age>(

select avg(age) from S S2 where S2.sex='女')

1.左右连接:以哪个表为主,结果集为“主表”的全部记录+“副表”与“主表”相匹配的记录,如果“副表”中没有和“主表”相匹配的记录,则相对应的记录显示为null

2.左连接:左边表全部行+右边表相匹配的行,如果左边表中的某一行,在右边表中没有匹配的行,则显示null(left

join

或者left

outer

join)

3.右连接:和左连接相反。(right

join

或者right

outer

join)

4.内连接:它返回字段id(连接条件)同时存在于两个表中的记录,也就是说,仅当至少有一个同属于两表的行符合联接条件时,内联接才返回行,内联接消除与另一个表中的任何行不匹配的行。(inner

join或者join)

5.全连接:不管匹配不匹配,全部都显示出来。(full

join或者full

outer

join)

6.交叉连接:没有where

子句的交叉联接将产生联接所涉及的表的笛卡尔积。第一个表的行数乘以第二个表的行数等于笛卡尔积结果集的大小。(cross

join不带where)

7.自连接:给自己取个别名,一个表当两个表来使用。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/6700677.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-27
下一篇 2023-03-27

发表评论

登录后才能评论

评论列表(0条)

保存