例子:把table2中李四的city和其他数据一起插入table1
insert into table1(id, name, age, sex, city) select '1001', '张三', '18', '男', t.city from table2 t where t.name='李四';
table1和table2的表结构不需要相同。
貌似不对啊
不对啊
追答是要把‘张三’与table1中的数据写到一个字段中吗?还是不同的字段?给一个table1和另一个表的表结构吧。
如果写在一个字段中:
insert into table2(field)
select '张三' union all select field from table1