Contenido del Curso
Introduction to SQL
Introduction to SQL
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:
¡Gracias por tus comentarios!