create table exam(
id int primary key auto_increment,
name varchar(20) not null,
chinese double,
math double,
english double
);
insert into exam values(null,'关羽',85,76,70);
insert into exam values(null,'张飞',70,75,70);
insert into exam values(null,'赵云',90,65,95);
insert into exam values(null,'刘备',97,50,50);
insert into exam values(null,'曹操',90,89,80);
insert into exam values(null,'司马懿',90,67,65);
1、查询表中所有学生的信息。
select * from exam;
2、查询表中所有学生的姓名和对应的英语成绩。
select name,english from exam;
3、过滤表中重复数据。
select distinct * from exam;
4、在所有学生分数上加10分特长分。
select * from exam set chinese=(chinese+10),math=(math+10),english=(english+10);
5、统计每个学生的总分。
select *,chinese+math+english from exam;
6、使用别名表示学生分数。
select *,chinese+math+english as 总分 from exam;
-----使用where子句
7、查询姓名为刘备的学生成绩
select * from exam where name='刘备';
8、查询英语成绩大于90分的同学
select * from exam where english>90;
9、查询总分大于200分的所有同学
select * from exam where chinese+math+english>200;
10、查询英语分数在 80-90之间的同学。
select * from exam where english between 80 and 90;
select * from exam where english>=80 and english<=90;
查询语句 ——select
最新推荐文章于 2023-03-19 19:56:14 发布
本文详细介绍了如何使用SQL语句进行学生信息的增删改查操作,包括创建表、插入数据、查询所有信息、筛选特定条件的学生记录,以及统计学生成绩等实用技巧。
2299

被折叠的 条评论
为什么被折叠?



