表A 字段 a,b,c,d,e,f
表B  l,m,n
A.e 和 B.l 关联 根据 A.e 查询 B.m
A.f 和 B.l 也关联 根据 A.f 查询 B.m最后要查询 
A.a,A.e(替换为B.m),A.f(替换为B.m)两表关联查询谢谢

解决方案 »

  1.   

    select *
    from a join b on a.e = b.l and a.f = b.m
      

  2.   

    select X.a,Y.m,Z.m
    from A x inner join B y on y.l = X.e
    inner join B z on z.l = X.f
      

  3.   

    select a.a,b.m,c.m
    from a
    join b on a.e=b.l
    join b as c on a.f=c.l
      

  4.   

    selex X.a,Y.m,Z.m
    from A X inner join B Y on Y.l = X.e
    inner join Z on Z.l = X.f
      

  5.   

    selex X.a,Y.m,Z.m
    from A X inner join B Y on Y.l = X.e
    inner join B Z on Z.l = X.f
      

  6.   


    select A.a,B1.m,B2.m
    from ta A
    left join tb B1 on A.e=B1.l and A.e=B1.m
    left join tb B2 on A.f=B2.l and A.f=B2.m
    where (B1.l is not null and B1.m is not null)
    or (B2.l is not null and B2.m is not null)
      

  7.   

    AcHerat囧 不是b.m b.l算了 都给分了。。嘿嘿