This should be simple but no matter what I try I can’t get the data I want…
I have two tables:
dependent d
empID relID dob
100 1 8/8/1988
100 2 1/1/2001
200 1 9/9/1989
employee e
empID
100
200
300
that I need to join like so:
Desired Results (where only dobs with relID=1 are included)
e.empID d.dob
100 8/8/1988
200 9/9/1989
300 NULL
No matter which join I use I end up with only the records that intersect (where the empID in dependent has a record with relID=1) like so:
Actual Results (see query below)
e.empID d.dob
100 8/8/1988
200 9/9/1989
SELECT e.empID, d.dob
FROM employee AS e LEFT OUTER JOIN dependent AS d ON e.empID = d.empID
WHERE (d.relID = 1)
What am I missing/doing wrong?
Thank you for your kind attention!
Make the filter part of the join condition: