把整个Mysql拆分成21天,轻松掌握,搞定(中)

把整个Mysql拆分成21天,轻松掌握,搞定(中)

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  21112 的数据 



前一天作业答案参考 


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  21112 的数据 

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 ;



标签:

  • 声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
  • 本文地址:https://www.609ai.com/shujuku/455.html
Mysql开源客户端Workbench 安装包
把整个Mysql拆分成21天,轻松掌握,搞定(下)