Finding Data that’s in One Table but not Another

Finding Data that’s in One Table but not Another

I have an employee table with a field empno (employee number) and an hours table that contains all time that is worked by all employees.The hours table has the empno field also. What I am trying to do is get a list of inactive employees; that is, all employees that haven’t any entries in the hours table. Is there a simple way to do this?

Sure. Try something like this:

SELECT empno FROM Employees     WHERE empno NOT IN (SELECT empno FROM Hours);


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist