Junior From PDF SQL SQL & Databases

What is the difference between IN and EXISTS in SQL?

Short answer: IN: Checks whether a value is present in a list or a subquery’s result set.

Explain a bit more

EXISTS: Checks whether a subquery returns any rows, returning TRUE if the subquery returns one or more rows, otherwise FALSE. Example with IN: SELECT name FROM employees WHERE department_id IN (SELECT id FROM departments WHERE name = 'HR'); Example with EXISTS: SELECT name FROM employees e WHERE EXISTS (SELECT 1 FROM departments d WHERE d.id = e.department_id AND d.name = 'HR');

Real-world example (ShopNest)

ShopNest’s SQL Server database stores customers, products, and orders. Good indexes and clear foreign keys keep checkout queries fast and safe.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details