Difference between IN and EXISTS
Answers were Sorted based on User's Feedback
Answer / udaykumar
IN - returns a numeric value.
EXIT - returns a boolean value.
| Is This Answer Correct ? | 7 Yes | 2 No |
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 |
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 |
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 |
What is sqlerrd?
What is the relation b/w view and trigger
what are the forced views
How do I tune a sql query?
What sql does db2 use?
Explain what is a database?
What is difference between nchar and nvarchar?
What are all the ddl commands?
First round ------------------- - Procedure - Packages - Views - Virtual tables - Can we use dcl with in function? - Joins and few scenarios - Triggers and its type - Pragma, type and its functionality - How to create db link in oracle - Materialized view - How to find duplicate values from table? - Cursor and its functionality - Write a script to display friday and its date from a entire year. - Exception Handling Second round ------------------------ Gave a scenario like. Need to write a function to perform. When user try to change a password. It must not be last five password and a given password can be combination of characters, symbols, upper and lower case.
What is data control language (dcl)?
How long will it take to learn pl sql?
Can we call a function containing dml statements in a select query?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)