当前位置: 代码迷 >> SQL >> sql 小结
  详细解决方案

sql 小结

热度:162   发布时间:2016-05-05 09:47:13.0
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

?

  相关解决方案