比如两个表 A(姓名,银行名,存款号) B(银行名) 
查询在所有银行都存过款的人的姓名
========>select 姓名 from A t where not exists
(select 1 from B where not exists(select 1 from B ,A where b.银行=a.银行 and a.姓名=t.姓名))

解决方案 »

  1.   

    select a.姓名 from a,b
    where a.银行名(+) = b.银行名
    group by a.姓名 having count(distinct a.银行名) = count(distinct b.银行名)
      

  2.   

    select 姓名 from A t where not exists
    (select 1 from B where not exists(select 1 from A t2 where b.银行=t1.银行 and t.姓名=t1.姓名))
      

  3.   

    select 姓名 from A t where not exists
    (select 1 from B where not exists(select 1 from A where 银行=b.银行 and 姓名=t.姓名))