select table1.* from table1, table2 where table1.e<>table2.a and table1.f<>table2.b

解决方案 »

  1.   

    上句错了,改为如下:
    select table1.* from table1 where (e,f) not in(select a,b from table2);
      

  2.   

    这样也行:
    select e, f from table1
    minus
    select a, b from table2;
      

  3.   

    怎么样都行。
    select * from table1 where e||f not in (select a||b from table2)
      

  4.   

    select * from table1
    minus
    select * from table2;
    我试了一下,如果表结构相同的话,用minus也很容易实现
    例:
    08:13:47 SQL> select * from a;    A_ID1     A_ID2 A_NAME
    --------- --------- ----------
            1         1 aaa
            2         1 A_21
            3         1 A_31实际:30
    08:13:55 SQL> select * from b;    A_ID1     A_ID2 B_NAME
    --------- --------- ----------
            2         1 B_111
            1         1 B_112
            1         1 aaa实际:20
    08:13:59 SQL> select * from a
    08:14:05   2  minus
    08:14:05   3  select * from b;    A_ID1     A_ID2 A_NAME
    --------- --------- ----------
            2         1 A_21
            3         1 A_31实际:20
    08:14:05 SQL>
      

  5.   

    sorry
    老眼昏花,Michaelyfj兄已经写了
    @-@
      

  6.   

    阿来说明一下,MINUS是求两个集合的差集的,类似的操作符还有:UNION[ALL]、INTERSECT;
    其中UNION是求2个集合的并集,加上ALL后选出的结果将包含2个集合中相同的各自的集合记录;
    INTERSECT是求2个集合的交集。集合操作符在一些方面的查询中是非常高效和灵活的,要掌握。
      

  7.   

    select * from table1 where not exists(select 1 from table2 where a=e and b=f)