SQL And
On this page
SQL AND Operator
The AND operator is used in a WHERE clause to combine multiple conditions. A record is returned only if all conditions are true.
Basic Syntax
SELECT column1, column2 FROM table_name WHERE condition1 AND condition2;
Example: Two Conditions
Return customers from the USA who are active:
SELECT name, country, status FROM customers WHERE country = 'USA' AND status = 'active';
Example: Numeric Filters
Return products with price over 100 and stock available:
SELECT name, price, stock FROM products WHERE price > 100 AND stock > 0;
Example: Date Range with AND
Return orders between two dates using two comparisons:
SELECT id, order_date FROM orders WHERE order_date >= '2026-01-01' AND order_date <= '2026-01-31';
Combine More Than Two Conditions
You can chain multiple AND conditions. All must be true for a row to match.
SELECT name, country, status FROM customers WHERE country = 'USA' AND status = 'active' AND email IS NOT NULL;
AND with OR: Use Parentheses
When mixing AND and OR, always use parentheses to make your logic explicit. Without parentheses, SQL applies operator precedence, which can produce unexpected results.
Example: customers in the USA who are either active or trial:
SELECT name, country, status FROM customers WHERE country = 'USA' AND (status = 'active' OR status = 'trial');
Common Mistakes
- Forgetting parentheses when combining AND and OR
- Comparing NULL with = instead of using IS NULL / IS NOT NULL
- Making conditions too broad and returning more rows than expected
Next Step
Continue with SQL OR to learn how to match records when at least one condition is true.