select * from a
union all select * from bselect * from a where ……
union all select * from b where ……

解决方案 »

  1.   

    --等值连接
    select * from a,b where a.主键=b.主键
    --左连接
    select * from a left join b on a.主键=b.主键
    --右连接
    select * from a right join b on a.主键=b.主键
      

  2.   

    --同构纵向连接
    select * from a union all select * from b--同构横向连接
    select * from a join b on a.id=b.id
    --异构横向连接
    select * from a join b on a.id=b.id--异构纵向连接,注意字段顺序.
    select *,null as 仅在b中存在的字段名 from a union all select *,null as 仅在a中存在的字段名 from b
      

  3.   

    select * from table1 where...
    union all
    select * from table2 where ....