您的位置:首頁技術文章
文章詳情頁

mysql - sql union 之后的結果與其他表join?

瀏覽:67日期:2022-06-15 16:59:37

問題描述

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) aleft join (select id,name from table3) b on a.id = b.id;

問題解答

回答1:

可以嘗試下臨時表、表變量;你最后這個應該也可以吧

相關文章:
国产综合久久一区二区三区