devxlogo

Finding Data that’s in One Table but not Another

Finding Data that’s in One Table but not Another

Question:
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?

Answer:
Sure. Try something like this:

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

See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

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