select customerId form Sales.Customers as C  ------ step 1
where not exists                           ----- step5
( select * from HR.Employees as E          -------step 2
      where country = 'USA'
      and not exists                           ------ step 4
     ( select * from Sales.Orders as O         ------ step3
       where O.customerId = C.customerId
          and O.employeeId = E.emploeeId
     ));
这个语句的执行顺序是我如上step步骤么?
谢谢。
数据库很久没碰,忘光了

解决方案 »

  1.   

    当访问到外部结果集的第一条记录时就将该外部记录带到到exis里面进行查询匹配,如果找到匹配的就退出exist,然后获取外部结果集的第二条记录并带入exist中进行匹配,依次类推,知道外部结果集的所有记录都获取完,所以正确的顺序如楼上说的,1,2,3,4,5
      

  2.   

    最先执行from
    然后where
    最后select