-->

MySQL AND

Summary: In this chapter, we will learn how AND operator to combine multiple Boolean expressions to form flex condition to filter data.

Introduction to MySQL AND operator

The MySQL AND operators are used to filter records based on more than one condition. The AND operator displays a record if both the conditions evaluate to true. The AND operator returns false if one of the two conditions evaluate to false.
1
WHERE boolean_expression_1 AND boolean_expression_2
The following illustrates the results of the AND operator when combining true, false, and null.
TRUEFALSENULL
TRUETRUEFALSENULL
FALSEFALSEFALSEFALSE
NULLNULLFALSENULL
The MySQL AND operator is often used in the WHERE clause of the SELECT, UPDATE, DELETE statement to form conditions to filter the result set. The MySQL AND operator is used in the join condition also.

MySQL AND operator examples

Let’s use the employees table in the sample database for the demonstration.
The following statement selects employees who is Software Engineer and whose salary is greater than 20000. For this scenario we need to use the AND operator in the WHERE clause.
Note: Using AND operator, we can combine more than two Boolean expressions also.
In this chapter, we have learnt how to use the MySQL AND operator to combine two or more expressions to form a complex predicate for the WHERE clause.

MySQL WHERE MySQL OR