
第8天作业 ,
继续 select
1)查找idoxu表,名称(c_name)包含 “i” 的数据
2)查找istester表,id 包含 “1” 的数据
3)查找istester表,id 包含 “1” 的数据,按id降序
4)查找istester表,id 包含 “1” 的数据 ,取id***的三个
前***作业答案参考 ,
1)查询istester表 id = 1的内容
select * from istester where id = 1;
2)查询idoxu 表 grade=100 的内容
select * from idoxu where grade =100;
/
第9天作业 ,
1)找出idoxu表中,分数***的同学和分数
2)找出idoxu表中,分数***的同学和分数
前***作业答案参考 ,
1)查找idoxu表,名称(c_name)包含 “i” 的数据
select * from idoxu where c_name like ‘%i%’ ;
2)查找istester表,id 包含 “1” 的数据
select * from istester where id like ‘%1%’;
3)查找istester表,id 包含 “1” 的数据,按id降序
select * from istester where id like ‘%1%’ order by id desc ;
4)查找istester表,id 包含 “1” 的数据 ,取id***的三个
select * from istester where id like ‘%1%’ order by id desc limit 3 ;
/
第10天作业 ,
-- 1) 找出istester表,sex为空的的数据;
-- 2)更新istester表,把sex为空的,设置为0(性别未知)
-- 3)找出idoxu表,grade小于60分的同学
-- 4)更新idoxu表,把grade小于60分的同学,一律改为59分
前***作业答案参考 ,
-- 1)找出idoxu表中,分数***的同学和分数;
SELECT c_name,grade as "maxvalue" from idoxu WHERE grade in (select MAX(grade) from idoxu ) ;
-- 2)找出idoxu表中,分数***的同学和分数;
SELECT c_name,grade as "minvalue" from idoxu WHERE grade in (SELECT MIN(grade) from idoxu );
/
第11天作业 ,
-- 1)查找istester表,按id降序
-- 2)查找idoxu表,按grade升序
前***作业答案参考 ,
-- 1) 找出istester表,sex为空的的数据;
select * from istester where sex is null ;
-- 2)更新istester表,sex为空的,设置为0(性别未知)
update istester set sex = 0 where sex is null ;
-- 3)找出idoxu表,grade小于60分的同学
select * from idoxu where grade < 60 ;
-- 4)更新idoxu表,把grade小于60分的同学,一律改为59分
update idoxu set grade = 59 where grade < 60 ;
/
第12天作业 ,
1)查询istester表,有多少条数据
2)查询istester表,有几种性别类型(sex字段,去重)
前***作业答案参考 ,
-- 1)查找istester表,按id降序
select * from istester order by id desc;
-- 2)查找idoxu表,按grade升序
select * from idoxu order by grade;
/
第13天作业 ,
1)查找idoxu表,学生成绩(grade) 总分
2)查找idoxu表,学生成绩(grade) 平均分
前***作业答案参考 ,
1)查询istester表,有多少行数据
select COUNT(sex) from istester;
2)查询istester表,有性别类型数量(sex字段,去重)
select COUNT(DISTINCT sex) from istester;
/
第14天作业 ,
1)查找idoxu表,成绩在80 - 100区间的学生 ;
2)查找istester表,id 为 2,11,12 的数据 ;
前***作业答案参考 ,
1)查找idoxu表,学生成绩(grade) 总分
select sum(grade) as sumgrade from idoxu ;
2)查找idoxu表,学生成绩(grade) 平均分
select avg(grade) as avggrade from idoxu ;
/
第15天作业 ,
1)删除 istester表,id大于12的数据 ;
2)删除idoxu表,分数grade不及格(小于60分)的数据 ;
前***作业答案参考 ,
-- 1)查找idoxu表,成绩在80 - 100区间的学生 ;
select * from idoxu where grade between 80 and 100;
-- 2)查找istester表,id 为 2,11,12 的数据 ;
select * from istester where id in (2,11,12) ;
/
第16天作业 ,
1)造数据 ,把istester表的所有数据,插入到 idoxu表
字段取值规则
id 取id
stu_id 取id
c_name 取 uname
istester 和 grade字段,给默认值 60
前***作业答案参考 ,
1)删除 istester表,id大于12的数据 ;
delete from istester where id > 12;
2)删除idoxu表,分数grade不及格(小于60分)的数据 ;
delete from idoxu where grade < 60 ;