I have the following tables:
Specialty
SpecialtyId Name IsEnabled
SpecialtyReport
UserId SpecialtyName ReportsRead
I am trying to figure out how to select all the records for a specific user from SpecialtyReport Table and then whatever Name is missing, populate it from Specialty Table and all other values can be null.
What I have tried is this:
SELECT s.Name, t.UserId, t.ReportsRead
FROM Specialty s
LEFT OUTER JOIN SpecialtyReport t ON s.Name = t.SpecialtyName
WHERE t.UserId = 1
However, the result that I get is same as if I did Inner join. The Specialty Table has about 10 rows and all with unique names, where as the SpeialtyReport Table has 3 rows with that User Id.
I can't figure out why the outer left join won't populate missing names. The end result I get from above query is just 3 rows.
EDIT:
The SpecialtyReport Table is made up, it comes from a subquery. I did a test where I created the actual table and my query works on it, but it doesn't work if I replace the table with results from a subquery. Why is that?