可以的,通过union all来实现。比如:select id,a username,b as col1,c as col2,d as col3,null as col4,null as col5,null as col6,null as col7  
from tableAunion allselect id,e username,f as col1,g as col2,h as col3,i as col4,j as col5,k as col6,l as col7
from tableB

解决方案 »

  1.   

    另外,如果希望更加方便,可以吧上面的代码 封装到一个试图中:create view tableA_tableB
    as
    select id,a username,b as col1,c as col2,d as col3,null as col4,null as col5,null as col6,null as col7  
    from tableAunion allselect id,e username,f as col1,g as col2,h as col3,i as col4,j as col5,k as col6,l as col7
    from tableB然后,你直接执行试图就可以了:select  * from tableA_tableB
      

  2.   

    用UNION ALL 是有要求的,数量要求一样,对应的列要,要求数据类型兼容要符合列数目一样,可以给列少的表在查询时加几个常量为NULL的列,对于相同位置的列,如果不能隐式转化成同数据类型的列,要自己CAST 或 CONVERT转化一下