sql union 之后的结果与其他表join?

sql1:

select id,name from table1;

sql2:

select id,name from table2;

union 合并表

select id,name from table1 
union 
select id,name from table2;

如何将union合并后的结果变成一张新表再与其他表进行join

如:

select * from 
(select id,name from table1 union select id,name from table2) a
left join 
(select id,name from table3) b on a.id = b.id;
阅读 9.2k
1 个回答

可以尝试下临时表、表变量;
你最后这个应该也可以吧

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题