如何将三个表链接成一个表查询出来?三个表可能有些字段是相同的,如何区分呢?

解决方案 »

  1.   


    derlare @t1 table(id int, col int)
    derlare @t2 table(id int, col int)insert @t1
    select 1,10 union all
    select 2,12 union all
    select 3,14  
    insert @t2
    select 1,10 union all
    select 1,12 union all
    select 3,14  
    select * from @t1 a left join @t2 b a.id=b.id
      

  2.   


    derlare @t1 table(id int, col int)
    derlare @t2 table(id int, col int)insert @t1
    select 1,10 union all
    select 2,12 union all
    select 3,14  
    insert @t2
    select 1,10 union all
    select 1,12 union all
    select 3,14  
    select * from @t1 a left join @t2 b on a.id=b.id