第一想法:
从分数表里面把小于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)
时间: 2024-10-07 19:20:21