I am using mysql and I have three tables T1, T2, T3
they contain data as follows:
+-------+
| t1.id |
+-------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+------+
+-------+
| t2.id |
+-------+
| 1 |
| 2 |
| 3 |
| 4 |
+-------+
+-------+
| t3.id |
+-------+
| 1 |
| 2 |
| 3 |
+-------+
I want to be able to select data as follows:
id t1.id t2.id t3.id
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 null
5 5 null null
How can I do this?
works, if
t1is guaranteed to have a strict superset of all ids.If not, you would need a helper table: