zoukankan      html  css  js  c++  java
  • 50个查询系列-第9个查询:查询所有课程成绩小于60分的同学的学号、姓名;

    第一想法:

    从分数表里面把小于60的学生id都查出来。

    SELECT tblstudent.StuId,tblstudent.StuName FROM tblstudent WHERE

    (
    SELECT  tblscore.Score FROM tblscore WHERE tblstudent.StuId=tblscore.StuId AND tblscore.Score<60

    )

    然后报错:

    Subquery returns more than 1 row
     是的呀。

    SELECT  tblscore.Score FROM tblscore WHERE tblstudent.StuId=tblscore.StuId AND tblscore.Score<60这句话查出来的数据有好几条呢。这样的当然是不对的。

    还是不知道怎么修改,于是看答案:

    select tblstudent.StuId,tblstudent.StuName from tblstudent where 
    tblstudent.StuId NOT IN
    (
    select  tblscore.StuId from tblscore where tblstudent.StuId=tblscore.StuId AND tblscore.Score>60)
  • 相关阅读:
    IOS开发--网络篇-->GCD(Grand Central Dispatch)的详解
    drf viewset
    12.6 drf 结构化组建
    12.5
    12.4
    12.3
    12.2
    12.1 angular vue react web前端三大主流框架的对比
    11.30
    11.28 过滤器的相关操作
  • 原文地址:https://www.cnblogs.com/shenxiaoquan/p/6121121.html
Copyright © 2011-2022 走看看