select * from dic a,
(select dic.col from dic , a where dic.col = a.col) union all
(select dic.col from dic , a where dic.col = b.col) union all
(select dic.col from dic , a where dic.col = c.col) union all
(select dic.col from dic , a where dic.col = d.col) union all
(select dic.col from dic , a where dic.col = e.col) )b
where a.col<>b.col

解决方案 »

  1.   

    你的意思是
    select * from dic a,
    ((select dic.col from dic , a where dic.col = a.col) union all
    (select dic.col from dic , b where dic.col = b.col) union all
    (select dic.col from dic , c where dic.col = c.col) union all
    (select dic.col from dic , d where dic.col = d.col) union all
    (select dic.col from dic , e where dic.col = e.col) )b
    where a.col<>b.col答案不对啊,取出了那几亿条数据.
      

  2.   

    select * from dic where not exists(select 1 from a where col=dic.col) and not exists(select 1 from b where col=dic.col) and not exists(select 1 from c where col=dic.col) and not exists(select 1 from d where col=dic.col) and not exists(select 1 from e where col=dic.col)
      

  3.   

    NOT IN 执行的是全表扫描   例如这个: select A.* from A where A.ID NOT IN 
     ( select B.ID from B)
     要对两个表进行全表扫描,你在sqlplus中看一下查询计划就知道了
      

  4.   

    最后一问,再哪个sqlplus 中看查询计划??sqlplus不是只有cmd下的界面和sqlplus工作单两个么?是看帮助中的sqlplus部分么?快结贴了
      

  5.   

    oracle 带的sqlplus.
     sql server 也有类似的,就是QA(查询分析器)
     要在sqlplus 中查看查询计划,要生成一个planTable的表,具体
     我就不多说了,这样的帖子太多了  最后说一句,很多人都回答了你的问题,楼主还没给分!
      呵呵
      

  6.   

    select t1.* from dic t1, 
    (
      select a.col from a
      union
      select a.col from b
      union
      select a.col from c
      union
      select a.col from d
      union
      select a.col from e
    ) t2
    where t1.col<>t2.col;
      

  7.   

    你要得到的是
    dic.col不在a, b, c, d, e表里的dic记录吧
      

  8.   

    我错了,第一次提问,分给的太少了,呵呵.bow.