我已经新建好一个作业任务了。任务描述如下:
第一步。
select A,B,C,D,E from 表A where 日期='2012-5-19'
第二步,请问怎么写,才能把查询出来的A,B,C,D的写入表B的A,B,C,D字段!

解决方案 »

  1.   


    insert into 表B 
    select A,B,C,D from 表A a where 日期='2012-5-19'
    and not exists (select 1 from 表B b
    where a.A=b.A and a.B=b.B and a.C=b.C and a.D=b.D)
      

  2.   

    insert into 表B
    select A,B,C,D from 表A a where 日期='2012-5-19'
    and a.A not in (select a from B)即可肯定有一个主键的
      

  3.   

    select a.a,a.b,a.c,a.d into tbB from A a
    where 日期=‘’