select 表1.a,表2.d
from 表1,表2
where 表1*=表2
order by 表1.a

解决方案 »

  1.   

    select 表1.a,IsNull(表2.d,0) from 表1,表2 where 表1.a*=表2.c
      

  2.   

    create table #a (a int,b varchar(10))
    create table #b (c int,d int)insert into #a values(101,'GSDSJ')
    insert into #a values(102,'GBSP')
    insert into #a values(103,'KKWU')
    insert into #b values(101,2001)
    insert into #b values(103,10000)select a.a,isnull(b.d,0)
    from #a a full join #b b
    on a.a=b.cdrop table #a
    drop table #b楼上的也可以。
      

  3.   

    Select 表1.a,IsNull(表2.d,0)
    From 表1 Left Join 表2 on 表1.a=表2.c
      

  4.   

    select a,IsNull(d,0) from 表1 left Outer join 表2 on 表1.id=表2.id