没有数据库先执行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;
  14. 查询所有学生的Sname、Cno和Degree列.
    Select sname,cno ,degree from student inner join score on student.sno=scire.sno;
  15. 查询“95033”班所选课程的平均分
    Select cno,avg(degree) as avg from score where sno in(select sno from student where class=’95033’)group by cno;
  16. 查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录
    Select degree from score where sno=’109’ and cno=’3-105’;
  17. 查询score中选学一门以上课程的同学中分数为非最高分成绩的记录
    Select sno from score group by sno having count(*)>1;
    Select * from score where sno in (Select sno from score group by sno having count(*)>1)
  18. 查询所有教师和同学的name、sex和birthday
    select sname as name,ssex as sex,sbirthday as birthday from student union select tname as name,tsex as sex,tbirthday as birthday from teacher;
  19. 查询所有“女”教师和“女”同学的name、sex和birthday
    select sname as name,ssex as sex,sbirthday as birthday from student where ssex='女' unio
  20. 查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录
    select * from score where DEGREE>(select DEGREE from score where sno='109'and CNO='3-105');
  21. 查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列
    Select sno,sname,sbirthday from student where year(sbirthday)=(select year(sbirthday) from student where sno=108);
  22. 查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列
    Select sno,sname,sbirthday from student where year(sbirthday)=(select year(sbirthday) from student where sno=108);
  23. 查询Student表中不姓“王”的同学记录
    Select * from student where sname not like '王%'
  24. 查询“张旭“教师任课的学生成绩
    Select degree from score,teacher,course where score.cno=course.cno and course.tno=teacher.tno and teacher.tname='张旭';
  25. 查询选修某课程的同学人数多于5人的教师姓名
    Select cno from score group by cno having count(*)>5;
    Select tname from teacher as t inner join course as c
    On t.tno=c.tno where cno in(Select cno from score group by cno having count(*)>5);
  26. 查询95033班和95031班全体学生的记录
    select * from student where class='95033' or '95031';
  27. 查询出“计算机系“教师所教课程的成绩表
    Select score.*from teacher as inner join course as con t.tno=c.cno inner join score as con c,cno=s.scno
  28. 查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。
    Select degree from score where cno=’3-105’
    And degree>all(Select degree from score where cno=’3-245’)
  29. 查询所有姓李的同学的sno,sname,cno,degree
    Select s.sno,sname,cno,degree from student as s inner join score as c no s.sno=c.sno where sname like ‘李%’;
  30. 查询成绩比该课程平均成绩低的同学的成绩表
    Select * from score where degree<(select avg (degree)from score as s where cno=s.cno);
  31. 查询所有任课教师的Tname和Depart
    select tname,depart from teacher where tno in (select tno from course where cno in (select distinct cno from score));
  32. 查询所有未讲课的教师的Tname和Depart
    select tname,depart from teacher where tname not in( select distinct tname from teacher,course,score where teacher.tno=course.tno and course.cno=score.cno);
  33. 查询至少有2名男生的班号
    select class from student where ssex='男' group by class having count(*)>1;
  34. 查询“男”教师及其所上的课程
    select tname,cname from teacher ,course where tsex='男' and teacher.tno=course .tno;
  35. 查询和“李军”同性别并同班的同学Sname
    select sname from student where ssex=(select ssex from student where sname='李军') and sname not in ('李军') and class =(select class from student where sname='李军');

MySQL查询语句练习集合相关推荐

  1. mysql查询语句详解_基于mysql查询语句的使用详解

    1> 查询数据表除了前三条以外的数据. 起初我想到的是这条语句 SELECT * FROM admin WHERE userid NOT IN (SELECT userid FROM admin ...

  2. 两小时学会MySQL查询语句(下篇)

    学生表 #创建表 CREATE TABLE LX_student( studentId INT(8) PRIMARY KEY NOT NULL, studentName VARCHAR(8) NOT ...

  3. 网上搜集的MySQL查询语句大全集锦(经典珍藏)

    原文地址为: 网上搜集的MySQL查询语句大全集锦(经典珍藏) SQL查询语句大全集锦 MYSQL查询语句大全集锦 1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql> SHOW ...

  4. mysql 查询语句执行顺序_MySQL 查询语句执行过程

    MySQL 查询语句执行过程 Mysql分为server层和存储引擎两部分,或许可以再加一层连接层 连接层(器) Mysql使用的是典型的C/S架构.连接器通过典型的TCP握手完成连接. 需要注的是, ...

  5. php面试专题---MYSQL查询语句优化

    php面试专题---MYSQL查询语句优化 一.总结 一句话总结: mysql的性能优化包罗甚广: 索引优化,查询优化,查询缓存,服务器设置优化,操作系统和硬件优化,应用层面优化(web服务器,缓存) ...

  6. mysql 查询语句_MySQL相关(一)- 一条查询语句是如何执行的

    前言 学习一个新知识最好的方式就是上官网,所以我先把官网贴出来 MySQL官网 (点击查阅),如果大家有想了解我没有说到的东西可以直接上官网看哈~目前 MySQL 最新大版本为8.0,但是鉴于目前应用 ...

  7. php通过数组存取mysql查询语句的返回值

    php通过数组存取mysql查询语句的返回值 1.示例1 $res = mysql_query($mysqli, $sql) or die(mysql_error($mysql)); $a=array ...

  8. java mysql查询语句_Mysql查询语句执行过程

    Mysql查询语句执行过程 Mysql分为server层和存储引擎两部分,或许可以再加一层连接层 连接层(器) Mysql使用的是典型的C/S架构.连接器通过典型的TCP握手完成连接. 需要注的是, ...

  9. MySQL查询语句执行过程及性能优化-基本概念和EXPLAIN语句简介

    网站或服务的性能关键点很大程度在于数据库的设计(假设你选择了合适的语言开发框架)以及如何查询数据上. 我们知道MySQL的性能优化方法,一般有建立索引.规避复杂联合查询.设置冗余字段.建立中间表.查询 ...

  10. left join 最后一条_一条Mysql查询语句的西天取经之路,你真的了解吗?

    数据库,大家都不陌生,这是程序员的基本技能了.当然,我们更多时候只是去了解如何使用数据库,而对数据库一些底层原理却比较陌生,今天我们来了解一下,一条数据库查询语句的取经之路. 基本分层 个人认为,My ...

最新文章

  1. 将图像转换为8位单通道_数字图像存储
  2. 探秘Hadoop生态12:分布式日志收集系统Flume
  3. 日志框架,选择Logback Or Log4j2?
  4. 【学习笔记】19、模快(Module)
  5. 【大数据教程】HDFS基本架构、基本命令、回收站机制和API操作
  6. 每日程序C语言18-求分数序列的前20项和
  7. 响应式web(三):服务当中的三种耦合,流式计算,RXJava2,Flux,Mono
  8. 关于加域后win7、win8的C:\不能够新建文件,报0X0070522错误的解决方式
  9. 单体测试书的检查要点
  10. DataTable对象的操作问题
  11. 微生物生态排序分析——CCA分析
  12. 在线画图工具ProcessOn
  13. 多张eps合并成一张
  14. GPIO输入输出各种模式(推挽、开漏、准双向端口)详解
  15. 家庭mesh组网方案
  16. 【感恩节的小礼物】yagmail给家人朋友来一份含有温情的关心和推送吧~Python3自动发送暖心内容邮件。
  17. 全面比较Aptos和Sui:Aptos已上线 来看看Sui
  18. Python|泰坦尼克号幸存者画像
  19. 查看jvm的运行参数
  20. 畅捷通T+密码清除后,空密码无法登录账套解决办法

热门文章

  1. 智慧农业大棚app是什么
  2. 2023-2024年华为ICT网络赛道模拟题库
  3. echarts 中国地图渲染 加省市渲染查询
  4. Notification 不起作用
  5. 基于JavaSE的淘宝卖鞋后端管理系统的设计与实现
  6. L175 Endorestiform Nucleus: Scientist Just Discovered a New Part of the Human Brain
  7. 【物联网 IoT 开发】Arduino 简介
  8. 基础 | date_range时间序列--时间切片
  9. linux 远程桌面:SSH
  10. 64. 基于 OData V4 的 SAP UI5 表格控件如何实现 filter(过滤) 和 sort(排序)功能