sql left联表查询将结果插入到别一数据库表中

a数据库多表查询

select
a.id,
a.title,
a.typeid,
b.body,
a.pubdate,
a.keywords,
a.description
from ras_archives a
left join ras_addonarticle b
on a.id=b.aid
where a.typeid = 8

将查询结果插入到新的数据表表中,注意字段的顺序。
insert into cd_content(content_id,title, class_id,detail,create_time,keyword,description) select
a.id,
a.title,
a.typeid,
b.body,
a.pubdate,
a.keywords,
a.description
from `www_wp1_com`.ras_addonarticle a
left join `www_wp1_com`.ras_addonarticle b
on a.id=b.aid
where a.typeid = 9

 

posted @ 2022-10-15 12:59  3000  阅读(118)  评论(0编辑  收藏  举报