Difference between IN and EXISTS

Answers were Sorted based on User's Feedback



Difference between IN and EXISTS..

Answer / udaykumar

IN - returns a numeric value.
EXIT - returns a boolean value.

Is This Answer Correct ?    7 Yes 2 No

Difference between IN and EXISTS..

Answer / anju saxena

The EXISTS operator tests whether a given set is empty or
not. An exist operator on empty set returns False while on
nonempty set it returns True.
IN operator is used where membership of the element has to
tested against the set.

Is This Answer Correct ?    8 Yes 4 No

Difference between IN and EXISTS..

Answer / subathra

IN: Inner query executes first and drives the outer query.
EXISTS: Outer query executes first and compares tge rows
retrived with the inner query.
Consider table tab1 has 1000 rows and table tab2 has 1000
rows.
IN: select t1.empid from tab1 t1 where t1.code in (select
t2.code from tab2 t2) -- All rows in t1 will read with t2
and the effect is 1000 X 1000 rows.
EXISTS: select t1.empid from tab1 t1 where exists (select 1
from tab2 t2 where t1.code=t2.code) -- Max of 1 row will be
read for each row of t1 and thus reduces the processing
overhead.
Thumb rule:
1) If the majority of the filtering are in the sub query
then use IN.
1) If the majority of the filtering are in the outer query
then use EXISTS.

Is This Answer Correct ?    4 Yes 0 No

Difference between IN and EXISTS..

Answer / yaswanth

IN looks for specified value and
EXISTS looks for whether particular row exists or not

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Dear All, Question for this Week Find out possible error(s) (either at compile time or at runtime) in the following PL/SQL block. State the reason(s) and correct the errors. Declare Cursor C1 is select ename, sal, comm from emp; Begin For i in C1 Loop If i.comm between 299 and 999 then Dbms_output.put_line(i.Ename || ‘ ** Good Commission’); Elsif i.comm > 999 then Dbms_output.put_line(i.Empno || ‘ ** Very Good Commission’); close C1; Else Dbms_output.put_line(i.Ename || ‘ ** ’ ||nvl(i.comm,‘O’)); End if; End Loop; End;

7 Answers   Accenture,


When to use inner join and left join?

0 Answers  


How is data stored on a disk?

0 Answers  


What are the different schemas objects that can be created using pl/sql?

0 Answers  


Explain architecture of sql server notification services?

0 Answers  






what are the advantages of mysql in comparison to oracle? : Sql dba

0 Answers  


What are predefined functions in sql?

0 Answers  


Explain the PL/SQL compilation process.

3 Answers  


How to fetch the rows by dynamicaly passing table name through cursor?

3 Answers  


Types of locks in database ?

8 Answers   HCL, TCS, Tieto,


What is cursor and its types?

0 Answers  


Can you have multiple SPs with the same name on a database?

2 Answers   CGI, Quest,


Categories