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

What is the difference between drop and truncate commands?

0 Answers  


explain normalization concept? : Sql dba

0 Answers  


Explain the methods used to protect source code of pl/sql.

0 Answers  


How do I make my sql query run faster?

0 Answers  


When we can declare a column as Unique and Not Null both at the same time. What is the use pf Primary Key then?

2 Answers   Accenture, Unisoft Infotech,






Can we change the table name in sql?

0 Answers  


What are the types pl/sql code blocks?

0 Answers  


How do you declare a variable in pl sql?

0 Answers  


I m giving Source, Destination and Age. Write a procedure or function, it will give to u this source to destination tickets are available or not, if available then check this person is senior citizen or not,if this person is senior citizen then give some discount. PLZ give this answer...... Thanks advance.....

3 Answers  


I have following column in the table. col1 1 a b c 2 3 d and I want to display it as num chars 1 a 2 b 3 c 4 d numbers in one column and letters in another column.

1 Answers   IBM, Saama Tech,


While inserting/updating million of records into a database table, how do I came to know how many records has been inserted or updated successfully so far?

2 Answers   HSBC,


Name Salary Abc 50000 Abc 50000 xyz 20000 find the max salary using aggregate function?

2 Answers   CTS,


Categories