mysql - sql union 之后的结果与其他表join?
本文介绍了mysql - 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;
解决方案
可以尝试下临时表、表变量;
你最后这个应该也可以吧
这篇关于mysql - sql union 之后的结果与其他表join?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文