I have two tables. The first table contains IDs (unique records), say, 100,000.
The second table does not contain all IDs of first table but may contain duplicate values.
First Table
ID int P.K
Name varchar(50)
Second Table
ID int F.K
Salary decimal(10,2)
I want to get all IDs from first table which are not in the second table using a high performance query.
Initially, I thought a poor way like:
select ID from table1 where ID not in (select distinct ID from table2)
Later, I worked out something like:
select A.ID from table1 A left join table2 B on A.ID = B.ID and salary is nullIs there any other way to get results with a high performance query?