sql - I need to get NULL values in Columns if Intermediate table doesn't apply -
i joining tables there 2 separate relationship schemes so:
tablea1 -> tablea2 -> tableb -> tablec : <<< relationship enter code here
and output needs so:
a1columnid a2columnid bcolumnid ccolumnid 1 1 1 1 2 null 2 2 3 null 3 3 4 2 4 4 5 null 5 5
if there exists these 2 relationship & b , need see a2colid null below relationship:
and 2nd relationship scheme looks so: tablea1->tableb-tablec <<<< relationship b (this scheme has no clue tablea2)
how join result set nulls in a2columnid depicted above?
left join
instead of regular join force table join if no data exists in right table, filling in null
in place. when join a1 , a2 so:
select * a1 left join a2 on a1.idlink = a2.idlink join b on a1.id = b.id join c on a1.id = c.id;
Comments
Post a Comment