select * from a XXXX join b on ....where .......
xxxx可以是:inner
right
left
full

解决方案 »

  1.   

    select * from 表1 where 条件1
    union all
    select * from 表2 where 条件2
      

  2.   

    select * from 表1 where 条件1
    union all
    select * from 表2 where 条件2
      

  3.   

    select * from a where 库a.dbo.表a.字段a = 库b.dbo.表b.字段b
      

  4.   

    左连接:left (full) join
    右连接:ritht (full) join
    外连接:outer (full) join
      

  5.   

    select a.xldm as lddm,a.xlmc as ldmc,c.xlmc as dfxl,
    c.fxymc as dfy,d.xlmc as fxxl,e.fxymc as fxr,f.xlmc as shxl,f.xm as shr into #lfy
    from xldm as a left join xldm as b on a.sjdm=b.xldm and left(b.xlmc,2)='DF'left join fxyxlb as c on b.xlmc=c.xlmc
    inner join xldm as d1 on right(a.xldm,5)=right(d1.xldm,5) and left(d1.xldm,1)='0'
    inner join xldm as d on d1.sjdm=d.xldm and left(d.xlmc,1)='F'
    inner join fxyxlb as e on d.xldm=e.xldm and left(e.xlmc,1)='F'
    inner join xldm as f1 on right(a.xldm,5)=right(f1.xldm,5) and left(f1.xldm,1)='0'
    left join shsz as f on f1.sjdm=f.xldm and left(f.xlmc,1)='S'
    where left(a.xldm,1)='8' and c.xlmc<>'' and f.xlmc<>''
    order by a.lddm
    仅供参考!!