有两 Table Table 1 :
A  B 
1  a
2  b
3  c 
4  d 
Table 2 :
A  C 
1  e
2  f
3  g 得到结果
A B C
1 a e
2 b f
3 c g
4 d 空   

解决方案 »

  1.   

    有两 Table Table 1 :
    A  B 
    1  a
    2  b
    3  c 
    Table 2 :
    A  C 
    1  e
    2  f
    3  g 
    4  h得到结果
    A B  C
    1 a  e
    2 b  f
    3 c  g
    4 空 h   
      

  2.   

    select nvl(table1.A,table2.A) A,table1.B,table2.C from table1  full outer join table2 on (table1.A=table2.A) ;
      

  3.   

    select m.a , nvl(n.b,'') b , m.c from table2 m left join table1 n on m.a = n.a
      

  4.   

    select t1.A ,t1.B,t2.C
    from tab1 t1,tab2 t2
    where t1.A(+)=t2.A
      

  5.   


    select tb1.a,tb1,b,tb2,c
    from tb1 left join tb2 on tb1.a=tb2.a
      

  6.   

    --或者这个:
    SELECT nvl(t1.A, t2.A) A, t1.B, t2.C
      FROM table1 t1, table2 t2
     WHERE t1.A = t2.A(+)
    UNION
    SELECT nvl(t1.A, t2.A) A, t1.B, t2.C FROM table1 t1, table2 t2 WHERE t1.A(+) = t2.A;
      

  7.   

    楼上几位大哥,感谢你们的回答哦.我写错题目了. :
    有两 Table Table 1 :
    A B 
    1 a
    1 b
    1 c 
    1 d Table 2 :
    A C 
    1 e
    1 f
    1 g 得到结果
    A B C
    1 a e
    1 b f
    1 c g
    1 d 空
      

  8.   


    select nvl(t1.a,t2.a) a,t1.b,t2.c
    from (select a,b,
    row_number() over(partition by a order by b) rn
    from tb1) t1 full outer join
    (select a,c,
    row_number() over(partition by a order by c) rn
    from tb2) t2
    on t1.a=t2.a and t1.rn=t2.rn