1、将一个表中数据查出插入另一张表中
insert into user(username,password,role) select code,'111','teacher' from teacher
2、根据查询结果更新
UPDATE MyTable INNER JOIN MyTable_Temp
ON MyTable.ID=MyTable_Temp.ID
SET MyTable.Col1=MyTable_Temp.Col1, MyTable.Col2=MyTable_Temp.Col2.....
3、将一个表中数据查询出添加到另一张表中
INSERT INTO clazz(code, stucount) SELECT DISTINCT clazz AS code,COUNT(*) AS stucount FROM student GROUP BY student.clazz