Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn 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:

sql

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:

sql

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

sql

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 8

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

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:

sql

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:

sql

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

sql

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