I have the following 3 tables:Create table a ( 1Code int, 2ID int, SomeData varchar)Create table b ( 1Code int, SomeName varchar)Create table c ( 2ID int, SomeName varchar)
I am wanting a join something like this:select 1Code, 2ID, SomeData, SomeNamefroma join b on a.1Code = b.1Code join((select * from (Select a.1Code, 2ID, SomeName from a left outer join b on a.1Code = b.1Code) a where SomeName is Null) b left outer joinc on b.2ID = c.2ID) d on a.2ID = d.2ID
I know the above is a mess and won't work, perhaps there is an easier way.What I am wanting is to join a & b where there is a match. Where there is no match between a & b then try to join a & c so that there is a value for SomeName for all records in a.Scott