表t1
id name
1  a
2  b
3  a
4  c表t2
id je
1  20
2  30
3  80
4  90怎么得到
t3
id name je 
1  a    20
2  b    30
3  a    80
4  c    90

解决方案 »

  1.   

    select a.*,b.jf  from ta a, tb b where a.id=b.id
      

  2.   

    select r.*,isnull(t.je,0) as je  from t1 r left join t2 t on r.id=t.id
      

  3.   

    select t1.id,t2.id as id2,name,je
    from t1
    join t2 on t1.id=t2.id
      

  4.   


    select a.*,b.jf  from ta a, tb b where a.id=b.id
      

  5.   

    你可以看看联合查询,用left outer join.select t1.id,name,je
    from t1 left outer join t2
    on t1.id=t2.id
      

  6.   

    select
     t1.id,t2.id as id2,name,je
    from
     t1
    join t2 on t1.id=t2.id
      

  7.   

    create table t1
    (
      id int,
      [name] varchar(20)
    )create table t2
    (
      id int,
      je varchar(20)
    )create table t3
    (
      id int,
      [name] varchar(20),
        je varchar(20)
    )insert into t1 values(1,'a')
    insert into t2 values(1,'20')insert t3 select t.id,t.[name],je from t1 t,t2
    select * from t3
    不知道符合要求不。不对的地方还请包涵。。
      

  8.   

    上面失误了:
    insert t3 select t.id,t.[name],je from t1 t,t2 tt where t.id=tt.id