在SQL中怎样将多张表的数据插入一张表中

那张大表的字段包含说有小表字段
2025-02-26 00:25:11
推荐回答(5个)
回答1:

如果列名都1致的话可以先把多张表的结果用unionall连起来以后作为1个表插入目标表中

回答2:

insert into big_tb (a,b,c,)
select t1.a,t2.b,t3.c
from t1,t2,t3
where t1.id=t2.id and t2.id=t3.id;

3个表为例 ,差不多就是这个形式 自己摸索一下就好

回答3:

insert into tablea (a,b,c)
select a,b,c from tableb
union all
select a,b,c from tablec
union all
select a,b,c from tabled

这是个原因,具体情况得看你建表的情况和你表字段的情况!

回答4:

insert into 表(列,……)
select ……
from table1 ,table2……

回答5:

先用select查出想要的结果,,,再adoquery1条1条的post上去