(1)有3个表t1,t2,t3,他们均有一个int类型的列id,t1的记录为(1),t2的记录为(1,1,2),t3的记录为(1,1,1,2,2)
分别写出下面2个sql 语句的执行结果
select t1.id,t2.id,t3.id from t1 left join t2 on t1.id = t2.id left join t3 on t3.id = t2.id
select t1.id,t2.id,t3.id from t1 left join t2 on t1.id = t2.id right join t3 on t3.id = t2.id
(2)有2个表t1,t2。他们各有2个列a,b表中记录内容如下:
t1表: ab t2表: ab
12 11
32 32
请写出查询不在t2表中出现,仅在t1表中存在的记录,注意判断的依据是整条记录,即已a,b字段为依据,例如,对
示例数据应该返回t1表中a=1,b=2这条记录。
(3)已知关系模式
S(sno,sname) 学生关系 sno为学号,sname为姓名
S1(cno,cname,cteacher) 课程关系 cno为课程号,cname为课程名,cteacher为任课教师
SC(sno,cno,scgrade)选课关系 scgrade为成绩
第3个问题:列出每个任课老师每门课程的课程名和不及格学生人数
额……老师都讲过,不过没有认真听
刚开始学,还不是很懂。。学习一下。。
额 没想到我都会做
帮顶,接分!
帮顶,接分!
帮顶,接分!
第二题
select t1.a,t1.b,t2.a,t2.b from t1 left join t2 on t1.a = t2.a and t1.b=t2.b where t2.a is null and t2.b is null;
给出 答案 学习一下
二题解
select * from t1 where not exists(select * from t2 where t2.a=t1.b and t2.b=t1.b)
CSS code
Code highlighting prod