Hi,
I have three tables that all have the same ID value in them. I have a query that where I want to bring back data joined on two tables, and include a value from a third table when it is in the 2nd table (otherwise null for that field). So basically I want to do an inner join on tbl1 and tbl2, and do a left join on that result set and tbl3. How would I code this?
I tried the following:
Select distinct tbl1.ID, tbl2.otherField, tbl3.anotherField
from tbl1 join tbl2
on tbl1.ID = tbl2.ID
left join tbl3
on tbl2.ID = tbl3.ID
but its returning too many rows. Maybe there's some things I don't understand about joins because when I did a left join for just 2 tables, it didn't return the same number of rows as the left-side table. Any ideas?
I have three tables that all have the same ID value in them. I have a query that where I want to bring back data joined on two tables, and include a value from a third table when it is in the 2nd table (otherwise null for that field). So basically I want to do an inner join on tbl1 and tbl2, and do a left join on that result set and tbl3. How would I code this?
I tried the following:
Select distinct tbl1.ID, tbl2.otherField, tbl3.anotherField
from tbl1 join tbl2
on tbl1.ID = tbl2.ID
left join tbl3
on tbl2.ID = tbl3.ID
but its returning too many rows. Maybe there's some things I don't understand about joins because when I did a left join for just 2 tables, it didn't return the same number of rows as the left-side table. Any ideas?