student表中的sname、ssex和sclass列

涉及表:student
涉及字段:sname、ssex、sclass

  1. mysql> select sname,ssex,sclass
  2. -> from student;
  3. +-------+------+--------+
  4. | sname | ssex | sclass |
  5. +-------+------+--------+
  6. | 李军 | | 95033 |
  7. | 陆君 | | 95031 |
  8. | 匡明 | | 95031 |
  9. | 王丽 | | 95033 |
  10. | 曾华 | | 95033 |
  11. | 王芳 | | 95031 |
  12. +-------+------+--------+
  13. 6 rows in set (0.00 sec)

student表的所有记录

涉及表:student
涉及字段:所有字段

  1. mysql> select * from student;
  2. +-----+-------+------+---------------------+--------+
  3. | sno | sname | ssex | sbirthday | sclass |
  4. +-----+-------+------+---------------------+--------+
  5. | 101 | 李军 | | 1976-02-20 00:00:00 | 95033 |
  6. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  7. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  8. | 107 | 王丽 | | 1976-01-23 00:00:00 | 95033 |
  9. | 108 | 曾华 | | 1977-09-01 00:00:00 | 95033 |
  10. | 109 | 王芳 | | 1975-02-10 00:00:00 | 95031 |
  11. +-----+-------+------+---------------------+--------+
  12. 6 rows in set (0.00 sec)

teacher表中所有不重复的系名

涉及表:teacher
涉及字段:depart
关键字:distinct

  1. mysql> select distinct depart from teacher;
  2. +------------+
  3. | depart |
  4. +------------+
  5. | 计算机系 |
  6. | 电子工程系 |
  7. +------------+
  8. 2 rows in set (0.00 sec)

teacher表中,每个系有多少个老师

  1. 使用 group by 按系名分组
  2. 求每组老师的数量:因为在教师表中每一行代表一名老师,所以每组老师的数量相当于每组的行数
  1. mysql> select depart,count(*)
  2. -> from teacher
  3. -> group by depart;
  4. +------------+----------+
  5. | depart | count(*) |
  6. +------------+----------+
  7. | 计算机系 | 2 |
  8. | 电子工程系 | 2 |
  9. +------------+----------+
  10. 2 rows in set (0.00 sec)

成绩在60到80之间的所有记录

  1. 查询score表中的指定记录
  2. 这些记录满足:degree在60和80之间
  1. mysql> select * from score
  2. -> where degree between 60 and 80;
  3. +-----+-------+--------+
  4. | sno | cno | degree |
  5. +-----+-------+--------+
  6. | 101 | 3-105 | 64.0 |
  7. | 105 | 3-245 | 75.0 |
  8. | 107 | 6-166 | 79.0 |
  9. | 108 | 3-105 | 78.0 |
  10. | 109 | 3-105 | 76.0 |
  11. | 109 | 3-245 | 68.0 |
  12. +-----+-------+--------+
  13. 6 rows in set (0.00 sec)

成绩为85,86,88的记录

  1. 查询score表中的指定记录
  2. 这些记录满足:degree为85,86,88

    方法一:使用关键字 in 方法二:使用关键字 or

  1. mysql> select * from score
  2. -> where degree in (85,86,88);
  3. +-----+-------+--------+
  4. | sno | cno | degree |
  5. +-----+-------+--------+
  6. | 101 | 6-166 | 85.0 |
  7. | 103 | 3-245 | 86.0 |
  8. | 105 | 3-105 | 88.0 |
  9. +-----+-------+--------+
  10. 3 rows in set (0.00 sec)
  11. mysql> select * from score
  12. -> where degree=85 or degree=86 or degree=88;
  13. +-----+-------+--------+
  14. | sno | cno | degree |
  15. +-----+-------+--------+
  16. | 101 | 6-166 | 85.0 |
  17. | 103 | 3-245 | 86.0 |
  18. | 105 | 3-105 | 88.0 |
  19. +-----+-------+--------+
  20. 3 rows in set (0.00 sec)

student表中,95031班级或性别为女的同学记录

方法一:使用关键字 or

  1. 查询student表中的指定记录
  2. 这些记录满足:sclass为’95031’,或ssex为’女’

方法二:使用关键字 union

  1. 查询sclass为’95031’的记录
  2. 查询ssex为’女’的记录
  1. mysql> select * from student
  2. -> where sclass=95031 or ssex='女';
  3. +-----+-------+------+---------------------+--------+
  4. | sno | sname | ssex | sbirthday | sclass |
  5. +-----+-------+------+---------------------+--------+
  6. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  7. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  8. | 107 | 王丽 | | 1976-01-23 00:00:00 | 95033 |
  9. | 109 | 王芳 | | 1975-02-10 00:00:00 | 95031 |
  10. +-----+-------+------+---------------------+--------+
  11. 4 rows in set (0.00 sec)
  12. mysql> select * from student where sclass=95031
  13. -> union
  14. -> select * from student where ssex='女';
  15. +-----+-------+------+---------------------+--------+
  16. | sno | sname | ssex | sbirthday | sclass |
  17. +-----+-------+------+---------------------+--------+
  18. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  19. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  20. | 109 | 王芳 | | 1975-02-10 00:00:00 | 95031 |
  21. | 107 | 王丽 | | 1976-01-23 00:00:00 | 95033 |
  22. +-----+-------+------+---------------------+--------+
  23. 4 rows in set (0.00 sec)

student表中,95033班和95031班全体学生的记录

  1. 查询student表中的指定记录
  2. 这些记录满足:sclass为’95033’,或sclass为’95031’

    方法一:使用关键字 in 方法二:使用关键字 or

  1. mysql> select * from student
  2. -> where sclass=95033 or sclass=95031;
  3. +-----+-------+------+---------------------+--------+
  4. | sno | sname | ssex | sbirthday | sclass |
  5. +-----+-------+------+---------------------+--------+
  6. | 101 | 李军 | | 1976-02-20 00:00:00 | 95033 |
  7. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  8. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  9. | 107 | 王丽 | | 1976-01-23 00:00:00 | 95033 |
  10. | 108 | 曾华 | | 1977-09-01 00:00:00 | 95033 |
  11. | 109 | 王芳 | | 1975-02-10 00:00:00 | 95031 |
  12. +-----+-------+------+---------------------+--------+
  13. 6 rows in set (0.00 sec)
  14. mysql> select * from student
  15. -> where sclass in (95033,95031);
  16. +-----+-------+------+---------------------+--------+
  17. | sno | sname | ssex | sbirthday | sclass |
  18. +-----+-------+------+---------------------+--------+
  19. | 101 | 李军 | | 1976-02-20 00:00:00 | 95033 |
  20. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  21. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  22. | 107 | 王丽 | | 1976-01-23 00:00:00 | 95033 |
  23. | 108 | 曾华 | | 1977-09-01 00:00:00 | 95033 |
  24. | 109 | 王芳 | | 1975-02-10 00:00:00 | 95031 |
  25. +-----+-------+------+---------------------+--------+
  26. 6 rows in set (0.00 sec)

student表中,所有不姓王的同学记录

  1. 查询student表中的指定记录
  2. 这些记录满足:不姓王
  1. mysql> select * from student
  2. -> where sname not like '王%';
  3. +-----+-------+------+---------------------+--------+
  4. | sno | sname | ssex | sbirthday | sclass |
  5. +-----+-------+------+---------------------+--------+
  6. | 101 | 李军 | | 1976-02-20 00:00:00 | 95033 |
  7. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  8. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  9. | 108 | 曾华 | | 1977-09-01 00:00:00 | 95033 |
  10. +-----+-------+------+---------------------+--------+
  11. 4 rows in set (0.00 sec)

以sclass降序查询所有学生记录

  1. 查询student表的所有记录
  2. 使用 order by 子句对查询结果降序排序
  1. mysql> select * from student
  2. -> order by sclass desc;
  3. +-----+-------+------+---------------------+--------+
  4. | sno | sname | ssex | sbirthday | sclass |
  5. +-----+-------+------+---------------------+--------+
  6. | 101 | 李军 | | 1976-02-20 00:00:00 | 95033 |
  7. | 107 | 王丽 | | 1976-01-23 00:00:00 | 95033 |
  8. | 108 | 曾华 | | 1977-09-01 00:00:00 | 95033 |
  9. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  10. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  11. | 109 | 王芳 | | 1975-02-10 00:00:00 | 95031 |
  12. +-----+-------+------+---------------------+--------+
  13. 6 rows in set (0.00 sec)


以cno升序,degree降序查询score表的所有记录

  1. 查询成绩表的所有记录
  2. 使用 order by 子句,对查询结果按cno和degree排序
  1. mysql> select * from score
  2. -> order by cno,degree desc;
  3. +-----+-------+--------+
  4. | sno | cno | degree |
  5. +-----+-------+--------+
  6. | 103 | 3-105 | 92.0 |
  7. | 107 | 3-105 | 91.0 |
  8. | 105 | 3-105 | 88.0 |
  9. | 108 | 3-105 | 78.0 |
  10. | 109 | 3-105 | 76.0 |
  11. | 101 | 3-105 | 64.0 |
  12. | 103 | 3-245 | 86.0 |
  13. | 105 | 3-245 | 75.0 |
  14. | 109 | 3-245 | 68.0 |
  15. | 101 | 6-166 | 85.0 |
  16. | 108 | 6-166 | 81.0 |
  17. | 107 | 6-166 | 79.0 |
  18. +-----+-------+--------+
  19. 12 rows in set (0.00 sec)

以班号和年龄从大到小查询student表的全部记录

  1. 查询学生表的所有记录
  2. 使用 order by 子句,对查询结果按班号和年龄降序排序
  3. 按年龄降序,等价于按出生日期升序
  1. mysql> select * from student
  2. -> order by sclass desc,sbirthday;
  3. +-----+-------+------+---------------------+--------+
  4. | sno | sname | ssex | sbirthday | sclass |
  5. +-----+-------+------+---------------------+--------+
  6. | 107 | 王丽 | | 1976-01-23 00:00:00 | 95033 |
  7. | 101 | 李军 | | 1976-02-20 00:00:00 | 95033 |
  8. | 108 | 曾华 | | 1977-09-01 00:00:00 | 95033 |
  9. | 103 | 陆君 | | 1974-06-03 00:00:00 | 95031 |
  10. | 109 | 王芳 | | 1975-02-10 00:00:00 | 95031 |
  11. | 105 | 匡明 | | 1997-10-02 00:00:00 | 95031 |
  12. +-----+-------+------+---------------------+--------+
  13. 6 rows in set (0.00 sec)

95031班的学生人数

  1. 筛选符合条件的学生
  2. 求学生人数
  1. mysql> select count(*) from student
  2. -> where sclass=95031;
  3. +----------+
  4. | count(*) |
  5. +----------+
  6. | 3 |
  7. +----------+
  8. 1 row in set (0.00 sec)

学生表中,最大和最小sbirthday 日期值

  1. 查询:最大日期、最小日期
    select 最大日期,最小日期 from 学生表
  2. 分别求最大日期和最小日期
    最大值:max(sbirthday)
    最小值:min(sbirthday)
  1. mysql> select max(sbirthday),min(sbirthday) from student;
  2. +---------------------+---------------------+
  3. | max(sbirthday) | min(sbirthday) |
  4. +---------------------+---------------------+
  5. | 1997-10-02 00:00:00 | 1974-06-03 00:00:00 |
  6. +---------------------+---------------------+
  7. 1 row in set (0.00 sec)

存在85分以上成绩的课程编号

题意:查询某个课程的编号

  1. 将成绩表按照课程编号cno分组
    group by cno
  2. 分组后再筛选,符合条件:组内最高成绩大于85
    having max(degree)>85
  3. 获得符合条件的组的课程编号cno
    select cno from score
  1. mysql> select distinct(cno) from score
  2. -> where degree>85;
  3. +-------+
  4. | cno |
  5. +-------+
  6. | 3-105 |
  7. | 3-245 |
  8. +-------+
  9. 2 rows in set (0.00 sec)
  10. mysql> select cno from score
  11. -> group by cno
  12. -> having max(degree)>85;
  13. +-------+
  14. | cno |
  15. +-------+
  16. | 3-105 |
  17. | 3-245 |
  18. +-------+
  19. 2 rows in set (0.00 sec)

子查询,查询score表中最高分的学号和课程号

题意:查询某个学生的学号和课程号

  1. 查询score表中的最高分
  2. 查询这个最高分所对应的学号和课程号
  1. mysql> select sno,cno from score
  2. -> where degree=(select max(degree) from score);
  3. +-----+-------+
  4. | sno | cno |
  5. +-----+-------+
  6. | 103 | 3-105 |
  7. +-----+-------+
  8. 1 row in set (0.00 sec)
  9. mysql> select sno,cno from score
  10. -> having max(degree);
  11. +-----+-------+
  12. | sno | cno |
  13. +-----+-------+
  14. | 101 | 3-105 |
  15. +-----+-------+
  16. 1 row in set (0.00 sec)

错误写法:

  1. mysql> select sno,cno from score
  2. -> where degree=max(degree);
  3. ERROR 1111 (HY000): Invalid use of group function

聚合函数不能用在条件语句中

3-105号课程的平均分

题意:查询某个课程的平均分

  1. 筛选符合条件的行
  2. 使用avg()函数,查询符合条件的行的平均分
  1. mysql> select avg(degree) from score
  2. -> where cno='3-105';
  3. +-------------+
  4. | avg(degree) |
  5. +-------------+
  6. | 81.50000 |
  7. +-------------+
  8. 1 row in set (0.00 sec)

score表中,至少有5名学生选修并且以3开头的课程的平均分

题意:查询某些课程的平均分

  1. 使用group by语句,按照课程编号分组
  2. 使用having子句筛选符合条件的组
  3. 使用聚合函数avg()对符合条件的组求平均值
  1. mysql> select avg(degree) from score
  2. -> group by cno
  3. -> having count(*)>5 and cno like '3%';
  4. +-------------+
  5. | avg(degree) |
  6. +-------------+
  7. | 81.50000 |
  8. +-------------+
  9. 1 row in set (0.00 sec)

score表中,最低分大于70分,最高分小于90分的sno

查询某些学生的学号

  1. 按学号对学生分组
  2. 使用having子句筛选符合条件的组
  3. 查询符合条件的组所对应的学号
  1. mysql> select sno from score
  2. -> group by sno
  3. -> having max(degree)<90 and min(degree)>70;
  4. +-----+
  5. | sno |
  6. +-----+
  7. | 105 |
  8. | 108 |
  9. +-----+
  10. 2 rows in set (0.00 sec)

所有学生的sname、cno和degree列

方法一:涉及两张表,使用连接查询

  1. 确定数据来源:student、score
  2. 使用inner join连接student和score
    student inner join score
  3. 使用on关键字指定连接条件
    on student.sno=score.sno
  4. 查询所需字段
    seelct student.sname,score.cno,score.degree
  1. mysql> select student.sname,score.cno,score.degree
  2. -> from student inner join score
  3. -> on student.sno=score.sno;
  4. +-------+-------+--------+
  5. | sname | cno | degree |
  6. +-------+-------+--------+
  7. | 李军 | 3-105 | 64.0 |
  8. | 李军 | 6-166 | 85.0 |
  9. | 陆君 | 3-105 | 92.0 |
  10. | 陆君 | 3-245 | 86.0 |
  11. | 匡明 | 3-105 | 88.0 |
  12. | 匡明 | 3-245 | 75.0 |
  13. | 王丽 | 3-105 | 91.0 |
  14. | 王丽 | 6-166 | 79.0 |
  15. | 曾华 | 3-105 | 78.0 |
  16. | 曾华 | 6-166 | 81.0 |
  17. | 王芳 | 3-105 | 76.0 |
  18. | 王芳 | 3-245 | 68.0 |
  19. +-------+-------+--------+
  20. 12 rows in set (0.00 sec)

方法二:使用where

  1. mysql> select student.sname,score.cno,score.degree
  2. -> from student,score
  3. -> where student.sno=score.sno;
  4. +-------+-------+--------+
  5. | sname | cno | degree |
  6. +-------+-------+--------+
  7. | 李军 | 3-105 | 64.0 |
  8. | 李军 | 6-166 | 85.0 |
  9. | 陆君 | 3-105 | 92.0 |
  10. | 陆君 | 3-245 | 86.0 |
  11. | 匡明 | 3-105 | 88.0 |
  12. | 匡明 | 3-245 | 75.0 |
  13. | 王丽 | 3-105 | 91.0 |
  14. | 王丽 | 6-166 | 79.0 |
  15. | 曾华 | 3-105 | 78.0 |
  16. | 曾华 | 6-166 | 81.0 |
  17. | 王芳 | 3-105 | 76.0 |
  18. | 王芳 | 3-245 | 68.0 |
  19. +-------+-------+--------+
  20. 12 rows in set (0.00 sec)

所有学生的sname、cname和degree列

方法一:涉及三张表,使用连接查询

  1. 确定内连接的表:student st、score sc、course c
  2. 使用inner join连接st、sc和c
    student st inner join score sc inner join course c
  3. 使用on关键字指定连接条件
    on st.sno=sc.sno and c.cno=sc.cno
  4. 查询所需字段
    seelct st.sname,c.cname,sc.degree
  1. mysql> select st.sname,c.cname,sc.degree
  2. -> from student st inner join score sc inner join course c
  3. -> on st.sno=sc.sno and c.cno=sc.cno;
  4. +-------+------------+--------+
  5. | sname | cname | degree |
  6. +-------+------------+--------+
  7. | 李军 | 计算机导论 | 64.0 |
  8. | 李军 | 数据电路 | 85.0 |
  9. | 陆君 | 计算机导论 | 92.0 |
  10. | 陆君 | 操作系统 | 86.0 |
  11. | 匡明 | 计算机导论 | 88.0 |
  12. | 匡明 | 操作系统 | 75.0 |
  13. | 王丽 | 计算机导论 | 91.0 |
  14. | 王丽 | 数据电路 | 79.0 |
  15. | 曾华 | 计算机导论 | 78.0 |
  16. | 曾华 | 数据电路 | 81.0 |
  17. | 王芳 | 计算机导论 | 76.0 |
  18. | 王芳 | 操作系统 | 68.0 |
  19. +-------+------------+--------+
  20. 12 rows in set (0.00 sec)

方法二:使用where

  1. 确定内连接的表:student st、score sc、course c
  2. 使用where子句筛选符合条件的行
  3. 在where子句中指定连接条件
    where st.sno=sc.sno and c.cno=sc.cno
  4. 查询所需字段
    seelct st.sname,c.cname,sc.degree
  1. mysql> select st.sname,c.cname,sc.degree
  2. -> from student st,course c,score sc
  3. -> where st.sno=sc.sno and c.cno=sc.cno;
  4. +-------+------------+--------+
  5. | sname | cname | degree |
  6. +-------+------------+--------+
  7. | 李军 | 计算机导论 | 64.0 |
  8. | 李军 | 数据电路 | 85.0 |
  9. | 陆君 | 计算机导论 | 92.0 |
  10. | 陆君 | 操作系统 | 86.0 |
  11. | 匡明 | 计算机导论 | 88.0 |
  12. | 匡明 | 操作系统 | 75.0 |
  13. | 王丽 | 计算机导论 | 91.0 |
  14. | 王丽 | 数据电路 | 79.0 |
  15. | 曾华 | 计算机导论 | 78.0 |
  16. | 曾华 | 数据电路 | 81.0 |
  17. | 王芳 | 计算机导论 | 76.0 |
  18. | 王芳 | 操作系统 | 68.0 |
  19. +-------+------------+--------+
  20. 12 rows in set (0.00 sec)

“张旭”教师任课的学生成绩

teacher.tno ⇔ course.tno ⇒ course.cno ⇔ score.cno ⇒ score.degree
查询“张旭”教师任课的学生成绩.png

  1. mysql> select sc.degree
  2. -> from teacher t inner join course c inner join score sc
  3. -> on t.tno=c.tno and c.cno=sc.cno
  4. -> where t.tname='张旭';
  5. +--------+
  6. | degree |
  7. +--------+
  8. | 85.0 |
  9. | 79.0 |
  10. | 81.0 |
  11. +--------+

同一个系中不同职称的教师的tname和pro

同一张表中两两对比,使用自连接:

  1. 查询某些教师的姓名和职称
  2. 这些教师要满足一些条件:系名相同,职称不同
  1. mysql> select distinct tname, pro from teacher where depart in ('计算机系', '电子工程系');
  2. +-------+--------+
  3. | tname | pro |
  4. +-------+--------+
  5. | 李诚 | 副教授 |
  6. | 王萍 | 助教 |
  7. | 刘冰 | 助教 |
  8. | 张旭 | 讲师 |
  9. +-------+--------+
  10. 4 rows in set (0.00 sec)

错误写法:

  1. mysql> select a.tname,b.pro
  2. -> from teacher a,teacher b
  3. -> where a.depart=b.depart and a.pro<>b.pro;
  4. +-------+--------+
  5. | tname | pro |
  6. +-------+--------+
  7. | 王萍 | 副教授 |
  8. | 李诚 | 助教 |
  9. | 张旭 | 助教 |
  10. | 刘冰 | 讲师 |
  11. +-------+--------+
  12. 4 rows in set (0.01 sec)

“计算机系”与“电子工程系”不同职称的教师的tname和pro

  1. mysql> SELECT tname,pro FROM teacher
  2. -> WHERE pro NOT IN
  3. -> (
  4. -> SELECT pro FROM teacher AS temp0
  5. -> WHERE depart = '计算机系'
  6. -> AND EXISTS (SELECT pro FROM teacher AS temp1
  7. -> WHERE depart = '电子工程系' AND temp1.pro = temp0.pro)
  8. -> );
  9. +-------+--------+
  10. | tname | pro |
  11. +-------+--------+
  12. | 李诚 | 副教授 |
  13. | 张旭 | 讲师 |
  14. +-------+--------+
  15. 2 rows in set (0.00 sec)
  16. mysql> select tname,pro from Teacher
  17. -> where Depart in ('计算机系','电子工程系') and Pro not in
  18. -> (select pro from Teacher where Depart='电子工程系' and Pro in
  19. -> (select Pro from Teacher where Depart='计算机系'));
  20. +-------+--------+
  21. | tname | pro |
  22. +-------+--------+
  23. | 李诚 | 副教授 |
  24. | 张旭 | 讲师 |
  25. +-------+--------+
  26. 2 rows in set (0.00 sec)

“计算机系”教师所教课程的成绩

方法一:连接查询

  1. mysql> select sc.degree
  2. -> from teacher t inner join course c inner join score sc
  3. -> on t.tno=c.tno and c.cno=sc.cno
  4. -> where t.depart='计算机系';
  5. +--------+
  6. | degree |
  7. +--------+
  8. | 86.0 |
  9. | 75.0 |
  10. | 68.0 |
  11. | 64.0 |
  12. | 92.0 |
  13. | 88.0 |
  14. | 91.0 |
  15. | 78.0 |
  16. | 76.0 |
  17. +--------+
  18. 9 rows in set (0.00 sec)

方法二:子查询(嵌套查询)

  1. 在teacher中,根据系名“计算机系”找出对应的教师编号tno
    select tno from teacher
    where depart=’计算机系’
  2. 在course中,根据教师编号tno查找这些教师对应的课程编号cno
    select cno from course
    where tno=(子查询1)
  3. 在score中,根据cno查找课程对应的成绩degree
    select degree from score
    where cno in (子查询2)
  1. mysql> select degree from score where cno =
  2. -> (select cno from course where tno=(select tno from teacher where depart='计算机系'));
  3. ERROR 1242 (21000): Subquery returns more than 1 row
  4. mysql> select degree from score where cno in
  5. -> (select cno from course where tno in (select tno from teacher where depart='计算机系'));
  6. +--------+
  7. | degree |
  8. +--------+
  9. | 86.0 |
  10. | 75.0 |
  11. | 68.0 |
  12. | 64.0 |
  13. | 92.0 |
  14. | 88.0 |
  15. | 91.0 |
  16. | 78.0 |
  17. | 76.0 |
  18. +--------+
  19. 9 rows in set (0.00 sec)

单行子查询可以使用比较运算符,但是多行子查询不能使用。