AND Operator

AND Operator explained with practical SQL patterns, edge cases, and production-ready guidance.

4 min read · Last updated: March 2026 · Back to overview

Quick Answer

The AND operator combines two boolean expressions and returns TRUE only when both are TRUE. It returns FALSE if either expression is FALSE, and NULL if one is NULL and the other is TRUE. AND is most commonly used in WHERE clauses to require multiple conditions simultaneously.

Spin up a Postgres database in 20 seconds with Vela.

Try Vela Sandbox

Introduction to the PostgreSQL AND operator

The AND operator is a logical operator that combines two boolean expressions. A boolean expression in PostgreSQL evaluates to one of three values: TRUE, FALSE, or NULL.

Basic syntax:

expression1 AND expression2

The truth table for AND:

  • TRUE AND TRUETRUE
  • TRUE AND FALSEFALSE
  • TRUE AND NULLNULL
  • FALSE AND FALSEFALSE
  • FALSE AND NULLFALSE (because one side is definitively false)
  • NULL AND NULLNULL

The key rule: AND returns TRUE only when both expressions are true. If either is definitively FALSE, the result is FALSE regardless of the other side.

Basic AND examples

SELECT true AND true   AS result;  -- t
SELECT true AND false  AS result;  -- f
SELECT true AND null   AS result;  -- null
SELECT false AND null  AS result;  -- f
SELECT null AND null   AS result;  -- null

Using AND in a WHERE clause

The most common use of AND is combining multiple filter conditions in a WHERE clause. All conditions joined by AND must be true for a row to be included in the result.

This query finds films from the DVD rental database that are longer than 180 minutes and have a rental rate below $1.00:

SELECT title, length, rental_rate
FROM film
WHERE length > 180
  AND rental_rate < 1;

Result:

title              | length | rental_rate
--------------------+--------+-------------
Catch Amistad      |    183 |        0.99
Haunting Pianist   |    181 |        0.99
Intrigue Worst     |    181 |        0.99
Love Suicides      |    181 |        0.99
Smoochy Control    |    184 |        0.99
(10 rows)

Chaining multiple AND conditions

You can chain as many conditions as needed. All must evaluate to TRUE for a row to pass the filter:

SELECT title, rating, length, rental_rate
FROM film
WHERE rating = 'PG'
  AND length BETWEEN 90 AND 120
  AND rental_rate <= 2.99;

AND with OR: precedence and parentheses

AND has higher operator precedence than OR, meaning it is evaluated first. This can lead to unexpected results when mixing them without parentheses:

-- Without parentheses: AND binds tighter, so this means:
-- (rating = 'G' AND length > 100) OR rental_rate < 1
WHERE rating = 'G' AND length > 100 OR rental_rate < 1;

-- Use parentheses to make intent explicit:
WHERE (rating = 'G' OR rental_rate < 1) AND length > 100;

Always use parentheses when combining AND and OR to avoid subtle logic errors.

NULL behavior with AND

Because any comparison with NULL produces NULL (not TRUE or FALSE), a condition like column = NULL never returns rows. Use IS NULL or IS NOT NULL explicitly:

-- Correct: find active customers with no phone on file
SELECT customer_id, first_name
FROM customer
WHERE active = 1
  AND phone IS NULL;

Reference: PostgreSQL documentation — Logical Operators.

Continue in Filtering Data: OR Operator.

Related in this section: PostgreSQL WHERE · OR Operator · LIMIT

Frequently Asked Questions

What does AND return when one expression is NULL?

It depends on the other expression. TRUE AND NULL returns NULL (unknown), because the outcome is uncertain. FALSE AND NULL returns FALSE, because even if the unknown side were TRUE, the overall result would still be FALSE. NULL AND NULL returns NULL.

What is the difference between AND and OR in PostgreSQL?

AND requires all conditions to be TRUE — it narrows results. OR requires at least one condition to be TRUE — it broadens results. AND has higher precedence than OR, so WHERE a AND b OR c is evaluated as WHERE (a AND b) OR c. Use parentheses when combining both operators to make precedence explicit.

Can I combine more than two conditions with AND?

Yes. You can chain as many conditions as needed: WHERE status = 'active' AND region = 'US' AND amount > 100 AND created_at >= '2024-01-01'. All conditions must evaluate to TRUE for a row to be included.

Does PostgreSQL short-circuit AND evaluation?

PostgreSQL does not guarantee short-circuit evaluation of AND conditions in the same way as programming languages. The query planner may reorder conditions for efficiency. If you need to guard against a NULL dereference or function side effect, use CASE expressions rather than relying on AND short-circuiting.

How does AND interact with indexes in PostgreSQL?

When multiple AND conditions each have their own index, PostgreSQL can use a BitmapAnd plan to combine the index bitmaps and find the intersection of matching rows. For highly selective combinations, a composite index covering all AND columns in the right order often performs better than separate single-column indexes.