sql 向表追加数据行 mysql java 好久没有不见了,困扰很久的问题在今天终于解决了,以前一直用 select * into? table1 from? table2 假如需要将table1 追加数据,却没有办法,只能用中间table3 select * into table3 from ( select * from table1 union all selec
sql 向表追加数据行 mysql java
好久没有不见了,困扰很久的问题在今天终于解决了,以前一直用
select * into? table1 from? table2
假如需要将table1 追加数据,却没有办法,只能用中间table3
select * into table3
from
(
select * from table1
union all
select * from table2
) data
--向表追加数据sql 语句
select * into #120 from
(
select 2 as source_type,d56.rkey,69 as fac from xxxxx d56
left join
(select * from data9287 where source_type =2) d9287 on d9287.source_ptr=d56.rkey
?where d9287.rkey is null and tdate>='2013-09-01'
)aa
go
insert into data9287(source_type,source_ptr,plant_ptr)select source_type,rkey,fac from #120
go
drop table #120
select * into #121 from
(
select 1 as source_type,d48.rkey,69 as fac from xxxxx d48
left join
(select * from data9287 where source_type =1) d9287 on d9287.source_ptr=d48.rkey
?where d9287.rkey is null and tdate>='2013-09-01'
)aa
go
insert into data9287(source_type,source_ptr,plant_ptr)select source_type,rkey,fac from #121
go
drop table #121