可以通过以下sql实现
sql:insert into tablename1(filename3,filename4) as select t2.filename1, t3.filename2 from tablename2 t2,tablename3 t3 where t2.id =t3.id;
解释:
从tablename2表中读取出filename1字段,从tablename3表中读取出filename2字段插入到tablename1表中的filename3,filename4字段。
后面的where条件是通过id字段,将查询的两张表关联起来确定依赖关系。
备注:插入表的字段顺序和查询表的字段顺序必须保持一致。
那样用你不觉得麻烦吗?我给你一简便的方法:
insert into 新表名称
select 信息1,信息2.... from 第一个表,第二个表 where 第一个表.A=第二个表.A
insert newtable select * from onetable
insert newtable select a.* from twotabe as a inner join onetable as b where a.tel=b.tel