Reputation: 2784
select principalTable.X, secondTable.ART, secondTable.DETT
from
(principalTable
left join thirdTable
on on principalTable.X = thirdTable.X
left join secondTable
on principalTable.ART = secondTable.ART and thirdTable.ID = secondTable.ID
)
I've got 3
tables that show some cross data from this query, I need a condition to select only the data from the secondtable
that had a common index with the thirdtable
, else without the and condition there can be many incorrect results.
I've tried the same query with the and
applied to principalTable
and with that,this work. With the condition applied on the thirdTable
it won't work.
Every advice is really appreciated.
Upvotes: 0
Views: 510
Reputation: 2189
try the following query.
select principalTable.X, secondTable.ART, secondTable.DETT
form principalTable pt,secondTable st,thirdTable tt
where pt.X = tt.X AND pt.ART = st.ART AND st.ID = tt.ID
Upvotes: 1