我有两笔完全不同数据,A表查询数据列是 a1,a2,a3B表查询数据列是 B1,b2,b3如何把数据整理显示成 a1,a2,a3,B1,b2,b3在线等

解决方案 »

  1.   

    select *  from A,B
      

  2.   

    select * from a
    union all
    select * from b
      

  3.   

    select * , null as b1,null as b2,null as b3 from A
    union all
    select null as a1,null as a2,null as a3,* from B
      

  4.   

    select * from A,B where ...
      

  5.   

    declare @tb1  table(col1 char(2),col2 char(2),col3 char(2))
    insert into @tb1
    select 'a1','a2','a3' declare @tb2  table(col1 char(2),col2 char(2),col3 char(2))
    insert into @tb2
    select 'B1','b2','b3' select *  from @tb1,@tb2/*
    col1   col2    col3    col1    col2    col3
    a1 a2 a3 B1 b2 b3*/
      

  6.   


    这种union all效果是
    declare @tb1  table(col1 char(2),col2 char(2),col3 char(2))
    insert into @tb1
    select 'a1','a2','a3' declare @tb2  table(col1 char(2),col2 char(2),col3 char(2))
    insert into @tb2
    select 'B1','b2','b3' select *  from @tb1
    union all
    select  *  from @tb2/*
    col1   col2    col3
    a1 a2 a3
    B1 b2 b3
    */