私は現在、2つのテーブル(右外部+左外部)で完全な外部結合をシミュレートする必要があり、結合を使用して重複を取り除く必要があります。完全な外部結合と連合MySQL
私はこれを行うテーブルがたくさんあるので、私は最終的に単一のテーブルで終わりたいと思っていました。これを行うにはより良い方法がありますか?
これは私が現在やっているものです:
create table `table+left` as(
select table1.col1, table1.col2, table1.col3, table2.col2 as `alias`
from table1
left outer join table2
on table1.col1 = table2.col1
);
create table `table+right` as(
select table1.col1, table1.col2, table1.col3, table2.col2 as `alias`
from table1
right outer join table2
on table1.col1 = table2.col1
);
create table `table1+table2` as
select * from `table+left`
union
select * from `table+right`;
私はこの名前付けポリシーで作業する必要がないことをご存じですか? – Strawberry
あなたは何をしたいですか?達成したいサンプルデータと結果を追加してください。 –
create table 'table + right'のselectは正しいですか?table1.col1、table1.col2、table1.col3のnullが得られるようですが、table1に一致するものはありませんか? –