I'm having a bit of trouble figuring out how to do this — I need to select all rows from table t1
, join table t2
— but include a null
row from t2
for each record in t1
(even if rows match in t2
).
For my case, I actually need to do this with four tables:
Table t1
has t1_id
, name
Table t2
has t2_id
, name
Table t3
has t3_id
, name
Table t4
has t4_id
, name
I need to join them all to get something like:
-----------------------------
t1_id | t2_id | t3_id | t4_id
-----------------------------
1 | NULL | NULL | NULL
-----------------------------
1 | 1 | NULL | NULL
-----------------------------
1 | 1 | 1 | NULL
-----------------------------
1 | 1 | 1 | 1
-----------------------------
This would be the final result of a join of the four tables, each having one row with an tx_id
of 1.
Best Answer
All INNER JOINs and UNIONs maybe
PROPOSED QUERY
SAMPLE DATA
PROPOSED QUERY EXECUTED
All the columns have id as a common name. If you want, I can adjust my answer with the id names