将查询结果作为临时表:
select * from (
select a.id as id,b.name as name from t_a a, t_b b where a.id=b.id
) as tmp
将查询结果插入到目表表:
- 表存在
- insert into 目表表 select * from 表 where 条件
- 表不存在 //经常不好用。
- select * into 目标表 from 表 where 条件
应用:N个表关键查询的结果存到t_new
insert into t_new select * from (
select a.id as id,b.name as name from t_a a, t_b b where a.id=b.id
) as tmp