日期:2014-05-18  浏览次数:20476 次

大家好,请问这个作业具体怎么做?
我已经新建好一个作业任务了。任务描述如下:


第一步。
select A,B,C,D,E from 表A where 日期='2012-5-19'


第二步,请问怎么写,才能把查询出来的A,B,C,D的写入表B的A,B,C,D字段!



------解决方案--------------------
SQL code

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)

------解决方案--------------------
探讨
引用:
SQL code

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)


如果日期改为系统时间的每天早上9点请问该……

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

------解决方案--------------------
select a.a,a.b,a.c,a.d into tbB from A a
where 日期=‘’