Finding Data that’s in One Table but not Another, Part 2

Finding Data that’s in One Table but not Another, Part 2

Let’s say I have two tables, one with the columns PositionIDand SkillID and one with the columns EmployeeID and SkillID.If I do a SELECT SkillID FROM First_Table WHERE PositionID=7,I will get a list of SkillIDs that PositionID=7 requires.If I do a SELECT SkillID FROM Second_Table WHERE EmployeeID=8,I will get a list of SkillIDs that EmployeeID=8 has.

If I do an INNER JOIN on the two tables I can easily get a listof the SkillIDs that the employee BOTH requires AND has butwhat I really want is a list of the SkillIDs that theemployee does NOT have. Is there anyway to do this in one SELECT statement?

You can solve for skills the employee does not have with the following query:

    SELECT * FROM Employees        WHERE employeeid=8 AND        skillid NOT IN             (SELECT skillid FROM Jobs WHERE positionid=7);
I had an additional question, very similar to this one, but where thecombination of two columns was needed to determine the data thatdid not exist in the second table. Remember that you also canconcatenate the columns if the unique data is not found in asingle column.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular