sql 总结

1,将查询结果作为临时表:

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

2,将查询结果插入到目表表:

2.1,表存在

insert into 目表表 select * from 表 where 条件

2.2,表不存在

select * into 目标表 from 表 where 条件

3,应用: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

猜你喜欢

转载自luckywnj.iteye.com/blog/2261480