数据库
首页 > 数据库> > sql 将查询结果插入已存在表

sql 将查询结果插入已存在表

作者:互联网

insert into  #check_wl
select t1.FItemID PId,t2.FItemID,t2.FQty 
from ICBOM t1 left join ICBOMCHILD t2 on t1.FInterID =t2.FInterID where  and FUseStatus=1072 and t2.FItemID>0
union all
select  t1.FItemID PId,t2.FItemID ,t2.FQty    from ICBOM t1 left join ICBOMCHILD t2 on t1.FInterID =t2.FInterID 
where  and FUseStatus=1072 and t2.FItemID>0

union all:并联的两个查询的字段数必须一致

insert into 已存在表名
select * from tablea
union all
select * from tableb

标签:union,t2,t1,插入,FItemID,sql,查询,select,FInterID
来源: https://blog.csdn.net/weixin_51803498/article/details/122512666