Having two table Tab_A and Tab_B. And the requirement is my query should return the result ( Tab_A - Tab_b) i.2 10,20,30 .
Tab_A Tab_B
10 40
20 50
30
40
50
Option -1: (Using minus)
Select * from Tab_A
minus
Select * from Tab_B;
Option -2: (Using Not In)
Select * from Tab_A
where Tab_A.c1 not in ( Select Tab_B.c1 from Tab_B);
Option - 3 (Using Left outer Join to Improve the query performance)
Select Tab_A.c1 from Tab_A left outer join Tab_b
on (Tab_A.c1=Tab_B.c1)
where Tab_b.c1 is null;
Please check the detail explanation :