Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Conditional Expressions: The AND Operator | Filtering Data
Introduction to SQL
course content

Course Content

Introduction to SQL

Introduction to SQL

1. Getting Started
3. Sorting Data
4. Populating a Database
5. Updating & Deleting Data

book
Conditional Expressions: The AND Operator

Summary:

The AND operator is used for joining multiple conditional expressions. The basic syntax for an AND operator joining two different conditional expressions is:

This is very useful in the SELECT statements when we want to conditionally select data. For example, the most common usage is when defining ranges.

Let's consider a situation where we want to fetch all of the employees that earn more than $50000 and less than $60000. We can do so by joining the following two expressions:

  • salary > 50000;
  • salary < 60000.

So the compound expression will look like: salary > 50000 AND salary < 60000.

Putting it inside a select statement will result into the following query:

It is important to note that we can chain together more than two conditions using the AND operator:

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 8
We're sorry to hear that something went wrong. What happened?
some-alt