SQL :a ,b两张表结构相同,要将a,b的内容复制到表c.
如果表a.name=b.name,则只复制表a的该列到表c,如何用SQL写?如果a.name!=b.name,则还需要将b表对应行复制到c...
如果表a.name = b.name,则只复制表a的该列到表c,如何用SQL写?
如果a.name != b.name,则还需要将b表对应行复制到c 展开
如果a.name != b.name,则还需要将b表对应行复制到c 展开
4个回答
展开全部
insert into c
(select *
from a
union all
select * from b where b.name not in (select a.name from a))
(select *
from a
union all
select * from b where b.name not in (select a.name from a))
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
insert into c select t0.XX from a t0 ,b t1 where t0.name = t1.name
insert into c select t1.XX from a t0 ,b t1 where t0.name <>t1.name
insert into c select t1.XX from a t0 ,b t1 where t0.name <>t1.name
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
insert into c
select a.* from a,b where a.name = b.name
select a.* from a,b where a.name = b.name
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
insert into c
(select * from a
union
select * from b
where not exists (select 1 from a where a.name=b.name )
(select * from a
union
select * from b
where not exists (select 1 from a where a.name=b.name )
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |