SQL Practice Logo

SQLPractice Online

IN, BETWEEN, EXISTS: Interview

Module: Advanced Filtering

What is the difference between IN and EXISTS?

IN tests if value matches any in a list. EXISTS tests if subquery returns any rows. EXISTS is often faster for subqueries because it stops at first match, while IN evaluates entire subquery.

Is BETWEEN inclusive or exclusive?

BETWEEN is inclusive - it includes both boundary values. WHERE x BETWEEN 10 AND 50 means x >= 10 AND x <= 50.

Find products with prices between $20 and $100

SELECT * FROM products WHERE price BETWEEN 20 AND 100;

BETWEEN provides clean syntax for range filtering, including both 20 and 100.