+ -
当前位置:首页 → 问答吧 → 数据插入问题

数据插入问题

时间:2011-12-10

来源:互联网

把tb2的数据插入tb1
注:要批量的,tb1本来就有数据


表结构如下

tb1

fhh  
203271 


tb2
jwsx#
203187  

想的结果

tb1

fhh  
203271
203187

作者: sddcs   发布时间: 2011-12-10



作者: zlcqupt   发布时间: 2011-12-10

SQL code
insert into tb1
 select * from tb2

作者: ssp2009   发布时间: 2011-12-10

如果是有多列的话,就指定列
SQL code

insert into tb1(fhh)
select jwsx# from tb2

作者: getdate123   发布时间: 2011-12-10

insert into
select

作者: sjcss   发布时间: 2011-12-10

SQL code


--将tb2中不包含在tb1中的数据插入tb1
create table tb1
(fhh varchar(100))

create table tb2
(jwsx# varchar(100))

insert into tb1 select '203271'
insert into tb2 select '203187'

insert into tb1
select * from tb2 t1 where not exists(select 1 from tb1 where fhh=t1.jwsx#)


作者: koumingjie   发布时间: 2011-12-10

SQL code
insert into tb1 select * from tb2 t where not exists(select 1 from tb1 where fhh=t.jwsx#)

作者: fredrickhu   发布时间: 2011-12-10