Postgresであればですが、full join が使えます。mysqlはUNIONでおこなえます。
<postgres>
insert into tbl_a values (100), (101), (200),(201);
insert into tbl_b values (100), (101), (300),(301);
select a.no, b.no from tbl_a a full join tbl_b b using(no);
no | no
-----+-----
100 | 100
101 | 101
200 |
201 |
| 300
| 301
<mysql>
select a.no, b.no from tbl_a a left join tbl_b b using(no)
union
select a.no, b.no from tbl_a a right join tbl_b b using(no);
+------+------+
| no | no |
+------+------+
| 100 | 100 |
| 101 | 101 |
| 200 | NULL |
| 201 | NULL |
| NULL | 300 |
| NULL | 301 |
+------+------+
6 rows in set (0.00 sec)
SqlServerもFULL JOINができました。
sql
1<SqlServer>
2 select a.no, b.no from tbl_a a full join tbl_b b on a.no=b.no;
3
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/19 12:52
2016/10/19 14:16
2016/10/19 17:21