I’m having a problem moving from a situation where an Outer Join works, to where it fails.
Working (pseudo code example)
SELECT a.number, a.name, b.ref, c.ref, c.firmref
FROM jobs a, teams b LEFT OUTER JOIN teamfirms c ON b.ref = c.team
WHERE a.ref = b.job
There is a many to one relationship between jobs and teams (many teams per job) that is always populated
There may or may not be firms in table c, but the query above gives me the result I would expect (approx 5000 records)
The problem comes when I want to bring in the details about the teams from a fourth table
The code I am trying is below
SELECT a.number, a.name, b.ref, c.ref, c.firmref, d.name
FROM jobs a, teams b LEFT OUTER JOIN teamfirms c ON b.ref = c.team, firms d
WHERE a.ref = b.job
AND d.ref = c.firmref
At this point the NULLS that I am trying to capture disappear and I drop approx 500 records
What am I doing wrong?
take a whack at this.
or you could do
one or the other… not both.
Just to throw this in for good measure…