MySQL查询语句练习1

没有数据库先执行50q数据库

  1. 查询student表中的所有记录的sname,ssex,class列
    select SNAME,SSEX,CLASS from student;
  2. 查询教师所有的单位即不重复的Depart列
    select distinct DEPART from teacher;
  3. 查询Student表的所有记录
    select * from student;
  4. 查询Score表中成绩在60到80之间的所有记录
    select * from score where degree between 60 and 80;
  5. 查询Score表中成绩为85,86或88的记录
    select * from score where degree=85 or degree=86 or degree=88;
  6. 查询Student表中“95031”班或性别为“女”的同学记录
    select * from student where class='95031' and ssex='女';
  7. 以Class降序查询Student表的所有记录
    select * from student order by class desc;
  8. 以Cno升序、Degree降序查询Score表的所有记录
    select * from score order by degree desc , cno;
  9. 查询“95031”班的学生人数
    select count(*) as '人数' from student where class='95031';
  10. 查询Score表中的最高分的学生学号和课程号
    select * from score order by degree desc limit 1;
  11. 查询‘3-105’号课程的平均分
    select avg(degree) from score where CNO='3-105';
  12. 查询Score表中至少有5名学生选修的并以3开头的课程的平均分数
    select cno,avg(degree) from score where cno like '3%' group by cno having count(sno)>5;
  13. 查询最低分大于70,最高分小于90的Sno列
    select sno from score group by sno having min(degree)>70 and max(degree)<90;
    在这里插入图片描述
    更多查询语句请参考MySQL查询语句集合
  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值