Back to Developer Roadmap

Exists Vs In

src/data/question-groups/sql-queries/content/exists-vs-in.md

4.0529 B
Original Source

EXISTS and IN are used in subqueries to filter results, but they perform different functions depending on their usage.

You should use EXISTS in the following situations:

  • When you want to check if a row exists and not the actual values.
  • When the subquery is a correlated query.
  • When the subquery returns many rows but you want to get the first match.

You should use IN in the following scenarios:

  • When you are comparing a column to a list of values.
  • When the subquery returns a small or static list.