zoukankan      html  css  js  c++  java
  • Mysql查询进阶

    #查询“生物”课程比“物理”课程成绩高的所有学生的学号;

     #需要用到临时表、连表、条件删选等知识点

    SELECT A.student_id FROM
    (SELECT sid,student_id,cname,num FROM score LEFT JOIN course on score.course_id=course.cid WHERE cid=1) AS A
    INNER JOIN
    (SELECT sid,student_id,cname,num FROM score LEFT JOIN course on score.course_id=course.cid WHERE cid=2) AS B
    on A.student_id=B.student_id WHERE A.num > B.num

    #查询没学过“叶平”老师课的同学的学号、姓名;

    #用到连表查询、多层查询、条件判断等知识点

    SELECT sid,sname FROM student WHERE sid NOT IN (SELECT student_id FROM score WHERE course_id IN (SELECT course.cid FROM teacher LEFT JOIN course on teacher.tid=course.teacher_id where teacher_id = 2) GROUP BY student_id);

    * 参考oldboy视频整理

  • 相关阅读:
    BGP
    ospf路由认证
    rip路由认证
    php-数组的相关函数及排序算法
    php-多维数组,数组遍历
    php-数组的概念,语法及特点
    php-错误处理
    MySQL性能优化
    JUC多线程03
    JUC多线程01
  • 原文地址:https://www.cnblogs.com/sparkss/p/11400029.html
Copyright © 2011-2022 走看看