Interview Core Track · Easy · 15 min
5. Finding Records in One Table Not Present in Another
To find records in one table that aren't in another, you can use a LEFT JOIN and check for NULL values in the right-side table. Here's an example using two t...
Company labels are directional practice context, not official interview guidance.
Objective
Practice joins through a Pinterest-tagged business scenario.
Approach
Use this track to improve speed, edge-case handling, and accuracy under timed conditions.
Company context
Company labels are directional practice context, not official interview guidance.
To find records in one table that aren't in another, you can use a LEFT JOIN and check for NULL values in the right-side table. Here's an example using two tables, Pinterest employees and Pinterest managers: SELECT * FROM pinterest_employees LEFT JOIN pinterest_managers ON pinterest_employees.id = pinterest_managers.id WHERE pinterest_managers.id IS NULL; This query returns all rows from Pinterest employees where there is no matching row in managers based on the id column. You can also use the EXCEPT operator in PostgreSQL and Microsoft SQL Server to return the records that are in the first table but not in the second. Here is an example: SELECT * FROM pinterest_employees EXCEPT SELECT * FROM pinterest_managers This will return all rows from employees that are not in managers. The EXCEPT operator works by returning the rows that are returned by the first query, but not by the second. ---
pinterest_employees
pinterest_managers
SQL workspace
Run queries against the protected question data, then submit once the result shape looks right.
Sign in to run SQL
Create a free account or sign in before running queries against protected question data.