表1字段 a,b,c
表2字段 a,b,c
表3字段 a,b,c
想从表1,表2,表3中选出a,b字段放到result表中,请问在一个sql语句中如何实现

解决方案 »

  1.   


    insert inito result
    select *
    from (
        select a,b,c
        from tb1
        union all
        select a,b,c
        from tb2
        union all
        select a,b,c
        from tb3
    )t
      

  2.   


    insert into result(a,b,c)
    select *
    from (
        select a,b,c
        from tb1
        union all
        select a,b,c
        from tb2
        union all
        select a,b,c
        from tb3
    )t
      

  3.   


    只要a,b字段,不要c字段,请问如何实现
      

  4.   

    select * into #result
    from (
        select a,b from tb1
        union all
        select a,b  from tb2
        union all
        select a,b from tb3
    )t
      

  5.   


    insert into result(a,b)
    select *
    from (
        select a,b
        from tb1
        union all
        select a,b
        from tb2
        union all
        select a,b
        from tb3
    )t