找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
#create table gl (id int(10) primary key auto_increment);
#desc gl;
#alter table gl add(name varchar(20),age int(11),class int(11),chinese int(11),english int(11),math int(11));
#alter table gl drop id;
#alter table gl add id int(11) first;
#alter table gl modify id int(11) primary key auto_increment;
#insert into gl(id,name,age,class,chinese,english,math)values
#(1,"zhangsan",21,1833,86,90,40);
#select * from gl;
#insert into gl values(2,"lisi",22,1832,55,86,66);
#insert into gl values(3,"wangwu",23,1832,84,90,88);
#insert into gl values(4,"zhaoliu",24,1833,93,57,98),(5,"liqi",25,1833,93,57,22),
#(6,"niuqi",26,1832,84,98,77),
#(7,"liuli",27,1832,56,57,77),
#(8,"wangbo",28,1833,48,58,88),
#(9,"wangsan",29,1832,78,57,88),
#(10,"wangan",30,1833,87,60,65),
#(11,"wangping",31,1832,80,76,88),
#(12,"wanghui",32,1833,null,79,88);
#1、查询1832班的成绩信息
#SELECT chinese,english,math from gl where class='1832';
#2、查询1833班,语文成绩大于80小于90的成绩信息
#select chinese,english,math from gl where class = '1833' and chinese > 80 and chinese < 90;
#3、查询学生表中5到10行的数据
#select * from gl where id limit 4,6;
#4、显示1832班英语成绩为98,数学成绩为77的姓名与学号;
#select 'name',id from gl where class='1832' and english='98'and math='77';
#5、查询出1832班成绩并且按语文成绩排序(降序);
#select * from gl where class=1832 order by chinese desc;
#6、查询1833班与1832班,语文成绩与数学成绩都小于80的姓名;
#select name from gl where (class=1833 or class='1832') and (chinese < 80 and math < 80);
#7、查询出没有参加语文考试的学生姓名和班级名称。
#select name,class from gl where chinese is null;
#8、求出班上语文成绩不及格的学生姓名
#select name from gl where chinese<60 or chinese is null;
#9、求出每个班的数学平均成绩
#select class, avg(math) from gl group by class;
#10、求出每个班级语文成绩总分 --涉及到每个的时候都需要分组
#select class,sum(chinese) from gl group by class;
#11、将语文成绩不及格的学生成绩改为60分
#update gl set chinese = 60 where chinese < 60 or chines is null;
#12、三科分数都大于70分的人名和年纪
#select name,age from gl where chinese > 70 and english > 70 and math > 70;
#select * from gl;
#13、求出英语分数高于70且其它任何一科目大于60分的人和班级
#select name,class from gl english > 70 and (chinese > 60 or math > 60);
#求出每个班英语成绩最高的分数和班级名称
#select class,max(english) from gl group by class;
#14、统计每个班的人数
#select class,count(*) from gl group by class;
#15、求每个班数学成绩大于80的人数
#select class,count(math) from gl where math > 80 group by class;
#16、求出每个班英语成绩最高的那个人的姓名和班级名称 --每个班英语成绩最高
#select name,class,max(english) from gl group by class;
#17、给gl表增加3个字段(数据类型及长度自定义,建议要合理)
#desc gl;
#alter table gl add(musice int(11),mysql int(11),python int(11));
#18、创建一个”dcs”远程用户授予该用户只有查询的权限
#use mysql;
#grant select on *.* to 'dcs'@'localhost' identified by '123456';

分享至 : QQ空间
收藏
您需要登录后才可以回帖 登录 | 立即注册