SQL如何将另一张表的某一字段里全部数值插入到本表中,同时保持不重复。
例:A表字段A 字段B
123 NULL
456 NULL
789 NULL
B表
字段A 字段B
123 NULL
456 NULL
789 NULL
012 NULL
345 NULL如何将B表里的 字段A 里的数值插入到 A表里的 字段A中,而且A表字段A已经有的值不插进去
请高手解答,在线等答案
例:A表字段A 字段B
123 NULL
456 NULL
789 NULL
B表
字段A 字段B
123 NULL
456 NULL
789 NULL
012 NULL
345 NULL如何将B表里的 字段A 里的数值插入到 A表里的 字段A中,而且A表字段A已经有的值不插进去
请高手解答,在线等答案
insert into A(字段a)
select 字段a
from B
where not exists (select 1 from A where 字段a = B.字段a)--where 字段a not in (select distinct 字段a from A)
select 字段a
from B
where not exists (select 1 from A where 字段a = B.字段a)
select from b
where a.字段A
not in (select 字段A from b)
select distinct * from b
where a.字段A
not in (select 字段A from b)[/code]
select distinct * from b
where a.字段A
not in (select 字段A from b)
select top 1 * from table_A where A=b.A )