Difference between IN and EXISTS
What is the difference between IN and EXISTS? Performance wise which one is better and how?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vinay SinghRank #604 · 4K reputationPosted Jun 14, 2016, 3:09 AM EDT
IN -- The inner query is executed first and the list of values obtained as its result is used by the outer query.The inner query is executed for only once.
EXISTS -- The first row from the outer query is selected ,then the inner query is executed and , the outer query output uses this result for checking.This process of inner query execution repeats as many no.of times as there are outer query rows. That is, if there are ten rows that can result from outer query, the inner query is executed that many no.of times.
Saurabh34 reputationPosted Jun 14, 2016, 3:23 AM EDT
Vinay SinghRank #604 · 4K reputationPosted Jun 14, 2016, 3:36 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jun 14, 2016, 5:12 AM EDT