20.查询所有学号为108、101的同学同年出生的所有学生的no 、name 、birthday 列。
year():选取日期的年份
select no,name,birthday from student
where year(birthday) in (select year(birthday) from student where no in(101,108));
这个语句也用到了子查询
21、查询 ‘张旭’ 教师任课的学生成绩表。
首先通过老师找到老师的编号,再通过老师的编号找到老师的课程号,最后通过课程号筛选出成绩表
select * from score
where c_no in (select no from course
where t_no in (select no from teacher where name='张旭')
);