sql server - Filtering with multiple joins -
sql server - Filtering with multiple joins -
i working in sql server 2008. know that, when joining 2 tables (call them , b), if want homecoming records in not in b, use:
select columns left bring together b on a.a_key = b.b_key b.b_key null in particular situation, trying bring together 3 tables, 1 of them intermediate table. let's phone call them a, b, , c. (b intermediate table.) here of import columns:
a: cola1, cola2
b: colb1, colb2
c: colc1, colc2
b.colb2 matches a.cola1, , c.colc1 matches b.colb1. goal homecoming records in not in c. so, best guess right is:
select columns left bring together b on a.cola1 = b.colb2 left bring together c on b.colb1 = c.colc1 c.colc1 null i know there records in not in c. however, query doesn't homecoming records. doing wrong? best guess @ moment joins wrong, since b intermediate table.
first inner join table b , table c. left join result table a records. seek this.
select * left bring together (select * b bring together c on b.colb1 = c.colc1) scd on a.cola1 = scd.colb2 scd.colb2 null sql-server
Comments
Post a Comment