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

bookConditional 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:

conditional_expression_1 AND conditional_expression_2

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:

SELECT * 
FROM employees 
WHERE salary > 50000 AND salary < 60000;

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

conditional_expression_1 AND conditional_expression_2 AND conditional_expression_3 …

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  8

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 2.  8
some-alt