看到网上流传的SQL50道经典练习题拿来作为复习。
数据表
先将在数据库中建立下面4张表,我使用的客户端Navicat for mysql。
1.学生表
student(s_id,s_name,s_age,s_sex)
s_id学生编号,s_name 学生姓名,s_age 出生年月,s_sex学生性别
create table students(
s_id varchar(10),
s_name varchar(10),
s_age datetime,
s_sex varchar(10)
);
insert into students values('01' , '赵雷' , '1990-01-01' , '男');
insert into students values('02' , '钱电' , '1990-12-21' , '男');
insert into students values('03' , '孙风' , '1990-12-20' , '男');
insert into students values('04' , '李云' , '1990-12-06' , '男');
insert into students values('05' , '周梅' , '1991-12-01' , '女');
insert into students values('06' , '吴兰' , '1992-01-01' , '女');
insert into students values('07' , '郑竹' , '1989-01-01' , '女');
insert into students values('09' , '张三' , '2017-12-20' , '女');
insert into students values('10' , '李四' , '2017-12-25' , '女');
insert into students values('11' , '李四' , '2012-06-06' , '女');
insert into students values('12' , '赵六' , '2013-06-13' , '女');
insert into students values('13' , '孙七' , '2014-06-01' , '女');
2.科目表
course(c_id,c_name,t_Id)
c_id 课程编号,c_name 课程名称,t_id教师编号
create table course(
c_id varchar(10),
c_name nvarchar(10),
t_id varchar(10)
);
insert into course values('01' , '语文' , '02');
insert into course values('02' , '