Course contentsShow
← Data Science
Lesson 866 of 2,14522. SQL FoundationsFree lesson

The AND Operator

Using AND to require multiple conditions to be true simultaneously, narrowing result sets with compound filters.

The AND Operator

You'll learn how to use AND to combine multiple conditions, filtering data only when all conditions are true simultaneously.

When filtering data with a WHERE clause, you'll often need rows that meet more than one requirement at the same time. The AND operator lets you stack conditions together, narrowing your result set to only those rows where every single condition evaluates to true.

How AND Works

Think of AND like a strict bouncer at an exclusive event checking multiple credentials. To get in, you need your ID and your ticket and proper attire—failing any one check means you're turned away. Similarly, a row must pass all conditions linked by AND or it won't appear in your results.

Basic Syntax

SELECT column1, column2
FROM table_name
WHERE condition1 AND condition2;

Practical Example

Suppose you're analyzing a sales table and want to find high-value recent transactions:

SELECT order_id, amount, order_date
FROM orders
WHERE amount > 1000 AND order_date >= '2024-01-01';

This returns only orders that cost more than $1000 and were placed in 2024 or later. An order with amount = 1500 but order_date = '2023-12-15' wouldn't appear—it fails one condition.

Combining Multiple ANDs

You can chain multiple AND operators:

SELECT product_name, category, price
FROM products
WHERE category = 'Electronics' AND price BETWEEN 100 AND 500 AND stock_quantity > 0;

This finds electronics priced between 100−100-500 that are actually in stock—three conditions, all must be true.

Key Takeaway: The AND operator requires all linked conditions to be true simultaneously, creating more restrictive, focused filters that narrow your dataset to precisely what you need.