mysql创建学⽣表
创建两张表1》学⽣基本信息表:姓名,性别,年龄
2》学⽣各科成绩表:科⽬,成绩,学期
题⽬
1、创建两张表
create table student(
s_id varchar(20)not null,
s_name varchar(20)not null,
s_sex varchar(20),
s_age varchar(20)not null,
primary key(s_id)
)
在sql查询语言中执行投影的运算符create table score(
判断bigdecimal是不是0s_id varchar(20)not null,
s_subject varchar(20)not null,
s_score integer,
s_term varchar(20)not null,
primary key(s_id)
)
2、向学⽣表插⼊两个学⽣“张三”‘李四’的基本信息,向成绩表插⼊张三,李四各学期,各科⽬的成绩insert into student values
('01','张三','男',20),三相异步电动机拆卸
('02','李四','男',21);
源码之家app免费模板
insert into score values
('01','语⽂',88,1),
('01','数学',78,1),
excel表格下拉选择('01','英语',63,1),
('02','语⽂',80,1),
mysql面试题学生表('02','数学',68,1),
('02','英语',53,1);
3、查询学⽣名字为张三的语⽂成绩
select s_name,s_score from score left join student on s_subject ='语⽂'
where s_name ='张三';
select s_id,s_score from score where s_subject ='语⽂'
4、查询所有⼥⽣的语⽂成绩的总和
select s_subject,sum(s_score)from score left join student on s_sex =‘⼥’
where s_subject ='语⽂'
5、查询所有学⽣中数学成绩排名前五的学⽣的姓名。
select s_name from student s_id in(
select s_id,s_score from score
group by s_id
order by subject ='数学' desc limit 0,5
)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。