<aside> 🔍 The WHERE clause filters rows based on conditions. Only rows matching the condition are returned.
</aside>
: Greater than
= : Greater than or equal to
-- 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
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>
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