select a.*.b.xx as xy
from a
join b on b.bb = a.dd
union all
select a.*,c.yy as xy
from a
join c on c.cc = a.dd

解决方案 »

  1.   

    select A.*,B.XX from A,B where A.DD=B.BB
    union all
    select A.*,C.YY from A,C where A.DD=C.CC
      

  2.   

    感覺是這樣Select
    A.AA,
    A.DD,
    IsNull(B.XX, C.YY) As XXYY
    From
    A
    Left Join
    B
    On A.DD = B.BB
    Left Join
    C
    On A.DD = C.CC
      

  3.   

    现在有3张表,A表有字段AA、DD,B表有字段BB、XX,C表有字段CC、YY,A表字段DD有可能是B表的BB或者C表的CC,要做一个查询包括A表的AA、DD,第三个字段根据DD显示XX或者YY,请问要怎么查呢?select a.aa,b.xx dd from a,b where a.dd = b.bb
    union all
    select a.aa,c.yy dd from a,c where a.dd = b.cc
      

  4.   

    select a.aa,b.xx dd from a,b where a.dd = b.bb
    union all
    select a.aa,c.yy dd from a,c where a.dd = c.ccdawugui(潇洒老乌龟),打錯了吧
      

  5.   

    但是是用where a.dd=b.bb还是from a join b on a.dd=b.bb效率高呢????
      

  6.   

    from a join b on a.dd=b.bb效率高
      

  7.   

    jy02945722() ( ) 信誉:100  2007-08-13 11:47:39  得分: 0  
     
     
       但是是用where a.dd=b.bb还是from a join b on a.dd=b.bb效率高呢????
      
    ---------
    一樣的
      

  8.   

    用union和用Left Join都可以實現 select A.*,B.XX from A,B where A.DD=B.BB
    union all
    select A.*,C.YY from A,C where A.DD=C.CC
     
     Select
    A.AA,
    A.DD,
    IsNull(B.XX, C.YY) As XXYY
    From
    A
    Left Join
    B
    On A.DD = B.BB
    Left Join
    C
    On A.DD = C.CC