You got two tables, both are lists of employees identified by a number, I want to find every one in [MyCompany] that isn't in the [OtherCompany] table. Why does this work:-
select MyCompany.staffno
from MyCompany
where staffno not in (select OtherCompany.EmpNumber
from OtherCompany
where EmpNumber = MyCompany.staffno)
But this doesn't:-
select MyCompany.staffno
from MyCompany
where staffno not in (select OtherCompany.EmpNumber from OtherCompany)
The only difference is the 'where' clause in the subquery, however the second query returns zero rows indicating that all rows in [MyCompany] already exist in the [OtherCompany] table which is not the case.