For at udføre FULL OUTER JOIN
du kan gør
LEFT OUTER JOIN
og UNION
med RIGHT OUTER JOIN
(forudsat at ):MySql
understøtter stadig ikke 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
Bemærk, at du kan bruge underforespørgsler til A
og B
- som burde fungere med dine forespørgsler. I dit tilfælde:
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
Med resultatet lig med (forudsat at jeg ikke lavede en fejl ved at kopiere dine data):
+------+-------+------------+----------+------+-------+------------+----------+
| _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 |
+------+-------+------------+----------+------+-------+------------+----------+