I am trying to do the following
select
TA.C1 ,TB.C1 ,TC.C1
from TableA TA ,TableB TB , TableC TC
where TA.C1 = "ABC"
AND TA.C2 = TB.C1
and TA.C3 = TC.C1
Result is
My aim is to add a couple more tables to this query
select
TA.C1,TB.C1,TC.C1,TD.C1,TE.C1
from TableA TA ,TableB TB , TableC TC , TableD TD, TableE TE
where TA.C1 = "ABC"
and TA.C2 = TB.C1
and TA.C3 = TC.C1
and TA.C4 = TD.C1
and TD.C2 = TE.C1
But since the Column TD.C1 contains null values , whereas TA.C4 always has some values , I get the below results.
The expected result is
I have tried joining using Joins for joining 4 tables :
select
TA.C1,TB.C1,TC.C1,TD.C1
from TableA TA
JOIN TableB TB ON (TA.C2 = TB.C1)
JOIN TableC TC ON (TA.C3 = TC.C1)
LEFT JOIN TableD TD ON (TA.C4 = TD.C1)
AND TA.C1 = "ABC"
The results is pretty near what I expect:
The issue is I'm not sure how to Join the 5th table (Table E) as this doesn't have any joing with Table A.