1.插入全部数据
insert into table1 select * from table2;
2.插入指定字段值
insert into table1(field1) select field1 from table2;
注意:
select之后的字段如果大于一个,不能用括号括起来,否则,系统会报错 :Operand should contain 1 column(s)
目标表的字段数 = 来源表的字段数
3.插入指定字段值+条件限制
insert into table1(field1) select field1 from table2 WHERE 条件;
4.从多个表查数据
INSERT INTO table1
SELECT t1.*, t2.* FROM
table2 t1
LEFT JOIN
table3 t2
ON t1.字段值 = t2.字段值