So I have the following data in a table.
ID Name fID mID
1 Bob 135 100
2 James Null 100
3 Graham Null 100
4 Gemma 142 100
What I want to do is return Bob, James, Graham, based on the fact that they are all under the mID of 100, but also that the fID is 135 or NULL. This excludes Gemma, since while she is under 100, she has an fID of 142 which is not 135 or NULL.
So far I have tried doing this:
SELECT ID, Name
FROM table1
WHERE mID=100 AND fID IN (SELECT fID FROM table1 WHERE fID=135 AND fID IS NULL)
But that returns nothing. Any suggestions helpful.