Forum Stats

  • 3,874,720 Users
  • 2,266,768 Discussions
  • 7,911,958 Comments

Discussions

Using Join instead of Minus or not in operator for improving query performance

Akshs
Akshs Member Posts: 70
edited May 3, 2016 12:24PM in Database Ideas - Ideas

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  :

Akshs
5 votes

Active · Last Updated

«1

Comments