table erbillno name
01      A
02      B
03      C
-------------
table opbillno name
01       A
02       B
05       E
----------------
我现在要取 billno  name
            03     C
            05     E
SQL语句是不是这样写 
                  select billno,name from table er
                union
                select billno,name from table op;

解决方案 »

  1.   

    select billno,name from table er 
                    minus 
                    select billno,name from table op;
    式式
      

  2.   

     select billno,name from table er 
     minus 
     select billno,name from table op;
      

  3.   

     (select billno,name from table er 
                    union 
                    select billno,name from table op)
               union all
               (select billno,name from table op 
                    union 
                 select billno,name from table er);
      

  4.   

    (select billno,name from table er 
                    minus 
                    select billno,name from table op)
               union all
               (select billno,name from table op 
                    [code=SQL]minus 
                 select billno,name from table er);[/code]是這樣的啊!
      

  5.   

    SQL> with a as (select '01' billno,'a' name from dual
      2             union
      3             select '02' billno,'b' name from dual
      4             union
      5             select '03' billno,'c' name from dual
      6             ),
      7      b as (select '01' billno,'a' name from dual
      8             union
      9             select '02' billno,'b' name from dual
     10             union
     11             select '05' billno,'e' name from dual
     12             )
     13  (select billno,name from a
     14  minus
     15  select billno,name from b)
     16  union
     17  (select billno,name from b
     18  minus
     19  select billno,name from a)
     20  /
     
    BILLNO NAME
    ------ ----
    03     c
    05     e
      

  6.   

    er - op 出来 billno name
                   03    Cunion all op - er 就出来5条了  谢谢楼上两位仁兄提示拉