这上用的表假设都有
select sname
from student
where exists
(select *
from sc
where sno=student.sno and cno='1');这句是选 选修1号课学生姓名
书上改了个 where not exists 就是 没选修1号课学生姓名 感觉对
但是我不明 where sno=student.sno and cno='1' 难道sno=student.sno不判断真假吗
如果 where sno!=student.sno and cno!='1'/cno='1'不也是一种情况吗
那么选出来的就不对了  但是这是书上原文应该没错 那就是我理解错了 指教一下呗

解决方案 »

  1.   

    exists是判断存在的
    你画一下逻辑图就清楚一些了
      

  2.   

    select sname 
    from student 
    where not exists 
    (select * 
    from sc 
    where sno=student.sno and cno='1');
    -- 从外向内循环对比 将外面记录对应的学号和SC表进行对比 找到相应记录 如果附加条件 cno='1' 说明这--个学生选了1号课程 返回假 这个记录排除
      

  3.   

    那也就是sno=student.sno不进行判断了?and后面的进行判断然后返回值
    感觉有点不合理 那么where sno='20021'and age<20;不都执行了吗
    我还是不太明白 where..and..返回真很好理解  返回假值是怎么返回的大家谁能讲一下吗?
      

  4.   

    返回真你理解了,返回假就是相反的啊where后返回真的取出来,返回家的派出掉啊 ,返回假的用select无法查出来