当前位置: 代码迷 >> Sql Server >> 一个表中的数据安插到另一个表
  详细解决方案

一个表中的数据安插到另一个表

热度:102   发布时间:2016-04-25 00:37:10.0
一个表中的数据插入到另一个表
如何将B表中的数据插入到B表中

注意:如果imei字段重复,则不插入

意思是说只插入不重复的数据。
------解决方案--------------------
B表数据插入A表中(设表结构相同,如不相同,则选择列进行操作):
insert into A
select * from B t where not exists(select 1 from A where imei=t.imei)
------解决方案--------------------
Insert into tb(字段)
Select 字段 From b
Where Not exists(select 1 from tb Where imei=b.imei)
------解决方案--------------------
因为在exsits/not exists里面要做表关联,你放出来,那里面就不知道成什么样了。
------解决方案--------------------
在not exists/exists外面的那些where条件,只对not exists/exists外面的那个/些表有效
------解决方案--------------------



insert into A(字段)
select 字段 
from B left join A on A.imei = B.imei
where A.imei is null

  相关解决方案