下面是主题给出来的查询语句
找出所有支行的集合中是否包含坐落在Brooklyn的所有支行的集合 
select distince S.customer_name
from depositor as S
where not exists((select branch_name
                  from branch
                  where branch_city = 'Brooklyn')
                  except
                  (select R.branch_name
                   from R.branch_name
                   where T.account_number=R.account_number and S.customer_name=T.customer_name))
这里两处..一处是not exists 一点都不明白..
另之处两个关系进行 except ? 是第一select branch_name  from branch where branch_city = 'Brooklyn') 拿出一行与下面的集合进行比较然后返回布尔值吗?

解决方案 »

  1.   

    exists不是已经给你解释过了?not exists取反不就行了?下面的except是两个集合相减。
      

  2.   

    1.‘not exists’ mean ‘not in’
    2.except从左查询中返回右查询没有找到的所有非重复值。
      

  3.   


    exists ,not exists 好比 in ,not in 
    except 两个表结构要相同,从左查询中返回右查询没有找到的所有非重复值。
      

  4.   

    下面是主题给出来的查询语句 
    找出所有支行的集合中是否包含坐落在Brooklyn的所有支行的集合 
    select distince S.customer_name 
    from depositor as S 
    where not exists((select branch_name 
                      from branch 
                      where branch_city = 'Brooklyn') 
                      except 
                      (select R.branch_name 
                      from R.branch_name 
                      where T.account_number=R.account_number and S.customer_name=T.customer_name)) 
    这里两处..一处是not exists 
    另之处两个关系进行 except ? 是第一select branch_name  from branch where branch_city = 'Brooklyn') 拿出的结合与排除下面的集合理解1:找出所有客户, 而这些客户在'Brooklyn'都有存折理解2:不存在在'Brooklyn'支行中的所有银行中没有开过所有存折的客户