有三张表  表1 A,B,C 三个字段
          表2 D,E,F 三个字段
   
表3 A,D两个字段
我现在要用批量插入的功能,从表1中得到A字段所有的值,从表2中得到D字段所有的值然后插入表3中。高人助我!

解决方案 »

  1.   

    insert into 表3(a,d) select a,d from 表1,表2
      

  2.   

    楼主没有给出表1和表2的关系阿,也就是说你要的A和D怎么该以怎样的组合形式插入的表3中
    我现在就取出max组合
    insert into 表3 (a,b) 
    select max(a) a, max(b) b 
    from (
                select rownum No, A, null D from 表1
                union all
                select rownum No, null A, D from 表2
    )
    group by No
      

  3.   

    insert into 表3(a,d)
    select A,D
      from (select distinct A from 表1) T1
        ,(select distinct D from 表2) T2
    ;