select tableA.*,tableB.* from tablea left join tableb on tabla.cola=tablb.cola

解决方案 »

  1.   

    create table a (cola int,colb char (1),colc char (2),cold char (3))
    create table b (cola int,cole char (1),colf char (2),colg char (3))insert into a (cola,colb,colc,cold)
    select 1,'x','xx','xxx' union all
    select 2,'x','xx','xxx' union all
    select 3,'x','xx','xxx' union all
    select 4,'x','xx','xxx' insert into b (cola,cole,colf,colg)
    select 2,'x','xx','xxx' union all
    select 4,'x','xx','xxx' select 
    isnull (a.cola,b.cola) as cola,
    isnull (a.colb,'') as colb,
    isnull (a.colc,'') as colc,
    isnull (a.cold,'') as cold,
    isnull (b.cole,'') as cole,
    isnull (b.colf,'') as colf,
    isnull (b.colg,'') as colg
    from a a full join b b
    on a.cola=b.cola
      

  2.   

    左连接:
    select tableA.col a ,col b,col c,cole e,col f,col g
    from tableA,tableB
    where tableA.a *= tableB.a