table1 custom    AV    quantity
AA        10     500
BB        100    100
DD        10     200
FF        20     20table2custom    AV    quantity
AA        20     1000
EE        10     100
DD        10     200
CC        20     200
要求得到如下结果custom    AV    quantity       custom    AV    quantity
AA        10     500            AA        20     1000
BB        100    100            null      null   null
DD        10     200            DD        10     200
FF        20     20             null      null   null
null      null   null           CC        20     200

解决方案 »

  1.   

    select * from table1 a full outer join table2 b on a.custom=b.custom
      

  2.   

    table2.custom = 'EE' 的记录怎么被筛选掉了?还是楼主列出的结果中遗漏?
      

  3.   

    libin_ftsafe(子陌红尘:当libin告别ftsafe)留点分给我们啊~~~create table table1(custom char(2),AV int,quantity int)
    insert table1 
    select 'AA',        10     ,500 union all
    select 'BB',        100    ,100 union all
    select 'DD',        10     ,200 union all
    select 'FF',        20     ,20
    --select * from table1create table table2(custom char(2),AV int,quantity int)
    insert table2
    select 'AA',        20     ,1000 union all
    select 'EE',        10     ,100 union all
    select 'DD',        10     ,200 union all
    select 'CC',        20     ,200 
    --select * from table2select A.*,B.*
    from table1 A full join table2 B on A.custom=B.customdrop table table1,table2
      

  4.   

    select * from table1 a full outer join table2 b on a.custom=b.custom这个是正解
      

  5.   

    YiZhiNet(温馨提示------开帖请结帖)
    你太职业了