use teachingdb;
/****请在此编写代码,操作完毕之后点击评测******/
/**********Begin**********/
select distinct student.sno,student.sname from score inner join student on student.sno=score.sno;
/**********End**********/
第4关:自身连接查询
任务描述
本关任务:使用自身连接查询求年龄大于'刘东明' 的所有学生的姓名与出生日期。
相关知识
为了完成本关任务,你需要掌握如何使用自连接。
自连接
MySQL 自连接操作,没有特定的关键字,所谓自连接指的是同一个表不同实例之间的 join 操作。
特征:
自连接是同一个表不同实例的连接操作;
自连接必须指定别名区分不同实例。
编程要求
在右侧编辑器补充代码,使用自身连接查询求年龄大于'刘东明' 的所有学生的姓名与出生日期。
测试说明
平台会对你编写的代码进行测试。
开始你的任务吧,祝你成功!
复制代码
use teachingdb;
/****请在此编写代码,操作完毕之后点击评测******/
/**********Begin**********/
select s1.sname ,s1.birthday from student s1 inner join student s2 on s2.sname='刘东明' where s1.birthday<s2.birthday;
/**********End**********/
use teachingdb;
/****请在此编写代码,操作完毕之后点击评测******/
/**********Begin**********/
select student.sno,sname from student left join score on score.sno=student.sno where score.cno is null;
/**********End**********/