Skip to main content
InterviewHubPRO
Section Overview
Q17

Question 17 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

34%
SQL & Relational Databases (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is the difference between `EXISTS` and `IN`?

senior LevelSystem Design

In Simple Words:

  • IN: Evaluates all subquery results, builds a candidate set, and checks if the outer value exists in that set. Fails or produces unexpected results if subquery returns NULL with NOT IN.
  • EXISTS: Returns a boolean true as soon as the first matching row is found (short-circuits immediately). Much faster when the subquery touches a large table with an index.