<aside> 🔍 The WHERE clause filters rows based on conditions. Only rows matching the condition are returned.

</aside>


1. Comparison Operators

-- Customers from Germany
SELECT * FROM customers WHERE country = 'Germany'

-- Customers NOT from Germany
SELECT * FROM customers WHERE country <> 'Germany'

-- Score greater than 500
SELECT * FROM customers WHERE score > 500

-- Score 500 or more
SELECT * FROM customers WHERE score >= 500

2. Logical Operators — AND, OR, NOT

Combine multiple conditions using AND, OR, NOT.

-- AND: Both conditions must be true
SELECT * FROM customers
WHERE country = 'USA' AND score > 500

-- OR: At least one condition must be true
SELECT * FROM customers
WHERE country = 'USA' OR score > 500

-- NOT: Negates the condition
SELECT * FROM customers
WHERE NOT score < 500

<aside> 💡 AND has higher precedence than OR. Use parentheses to control evaluation order.

</aside>


3. Range Filtering — BETWEEN

BETWEEN is inclusive on both ends.

-- Score between 100 and 500 (inclusive)
SELECT * FROM customers
WHERE score BETWEEN 100 AND 500

-- Equivalent to:
SELECT * FROM customers
WHERE score >= 100 AND score <= 500