1>select * from w_student a where exists (select 1 from w_student b where b.sno = 101 and b.sno = a.sno) 
中'1'有什么特殊的含义呢(也可以替换成* 吧)
   2>说下它执行的顺序

解决方案 »

  1.   

          顺便说下这条语句
           3>select * from w_student a where  exists  (select sno from w_student b   b.sno=102)
      

  2.   

    1: "1"没有什么特殊含义 ,可以替换
    2:执行顺序可以看该语句的执行计划,用plsql developer或toad等工具都可以查看,也可以sqlplus查看。
    这种exists语句应该是先全表扫描w_student a,然后查询w_student b
      

  3.   

    select * from w_student a where  exists  (select sno from w_student b  b.sno=102)
    虽然不知道你到底想要做什么?这条语句是有问题的,只要w_student这个表中有一条sno=102的,你这条语句返回的就是w_student的所有记录数。如果没有一条记录为102的你就一条记录不会返回。
    所以这条语句只有两种结果,要么全部记录  要么一条记录没有。exists只是一个判断语句。从父查询中查出一条记录就会到子查询中判断,如果子查询能够返回记录既非空,那么这条记录不被过滤,否则父查询的这条记录会被过滤。--表达起来有点不清楚,不知道你是否能够看明白,自己多做下实验就明白了。看看书里面是怎么说的吧。