Om de FULL OUTER JOIN
. te doen je kunt doen
de LEFT OUTER JOIN
en UNION
met RIGHT OUTER JOIN
(op voorwaarde dat ):MySql
ondersteunt nog steeds geen FULL OUTER JOIN
select * from A as a
left outer join B as b on a.col = b.col
union
select * from A as a
right outer join B as b on a.col = b.col
Merk op dat u subquery's kunt gebruiken voor A
en B
- die zou moeten werken met uw vragen. In jouw geval:
select * from (SELECT * FROM t1) as a
left outer join (SELECT * FROM t2) as b on a._tid = b._tid
union
select * from (SELECT * FROM t1) as a
right outer join (SELECT * FROM t2) as b on a._tid = b._tid
Met resultaat gelijk aan (mits ik geen fout heb gemaakt bij het kopiëren en plakken van uw gegevens):
+------+-------+------------+----------+------+-------+------------+----------+
| _id | _tid | _dt | _advance | _id | _tid | _dt | _advartn |
+------+-------+------------+----------+------+-------+------------+----------+
| 17 | hjg | 2012-04-18 | 2151 | NULL | NULL | NULL | NULL |
| 22 | RKT01 | 2012-04-10 | 2098 | NULL | NULL | NULL | NULL |
| 14 | RKT04 | 2012-04-18 | 1511 | 8 | RKT04 | 2012-04-20 | 150 |
| 16 | RKT09 | 2012-04-09 | 250 | NULL | NULL | NULL | NULL |
| 15 | RKT10 | 2012-04-17 | 1313 | NULL | NULL | NULL | NULL |
| 8 | RKT21 | 2012-04-03 | 1321 | NULL | NULL | NULL | NULL |
| 19 | RKT31 | 2012-04-26 | 2512 | NULL | NULL | NULL | NULL |
| 20 | RKT33 | 2012-04-10 | 2250 | NULL | NULL | NULL | NULL |
| 25 | T01 | 2012-04-11 | 2500 | NULL | NULL | NULL | NULL |
| NULL | NULL | NULL | NULL | 9 | RKT02 | 2012-04-10 | 2500 |
+------+-------+------------+----------+------+-------+------------+----------+