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;
可以尝试下临时表、表变量;
你最后这个应该也可以吧