sql1复习笔记7
1.查询练习-year函数与带in关键字的子查询
查询和学号为108/101的同学同年出生的所有学生的sno、sname和sbirthday列
思路
//先看108和101是哪年出生的
select * from student where sno in (108,101);
//发现是1977和1975
select year(sbirthday) from student where sno in (108,101);
//筛选
select * from student where year(sbirthday) in (108,101);
先选出来这两个人的年份,然后把选的语句作为条件。
2.查询练习-多层嵌套子查询
查询张旭教师任课的学生成绩
select tno from teacher where tname='zhangx