You didn't join the table in your query.
Your original query will always return nothing unless there are no records at all in eotm_dyn
, in which case it will return everything.
Assuming these tables should be joined on employeeID
, use the following:
SELECT *
FROM employees e
WHERE NOT EXISTS
(
SELECT null
FROM eotm_dyn d
WHERE d.employeeID = e.id
)
You can join these tables with a LEFT JOIN
keyword and filter out the NULL
's, but this will likely be less efficient than using NOT EXISTS
.