I have a list of tables like this:
t1
ID | Name
3 | 'AAA'
4 | 'BBB'
5 | 'CCC'
6 | 'DDD'
7 | 'EEE'
t2
ID | Password
3 | 'test'
6 | 'password'
t3
ID | Birth Year | Last Name
4 | 1990 | 'John'
6 | 1988 | 'Megan'
7 | - | 'Bob'
t4
ID | Birth Year
7 | 1985
I want to merge them all into this, noticing that t3 and t4 both have birth year columns, but the value will only be in either one.
ID | Name | Password | Birth Year | Last Name
3 | 'AAA' | 'test' | - | -
4 | 'BBB' | - | 1990 | 'John'
5 | 'CCC' | - | - | -
6 | 'DDD' |'password'| 1988 | 'Megan'
7 | 'EEE' | - | 1985 | 'Bob'
Does anyone know how this can be done? t1 is the "master" table, so it will always contain all the IDs.
I've tried:
select * \
from t1 \
LEFT outer join t2 on t1.ID = t2.ID \
LEFT outer join t3 on t1.ID = t3.ID \
LEFT outer join t4 on t1.ID = t4.ID
But it doesnt work properly, it has separate columns for each individual columns in t1, t2, t3, t4