MySQL

AND Operator in MySQL

In this tutorial, we are going to see how the AND operator combines multiple Boolean expressions to filter data. The AND operator is a logical operator that combines two or more Boolean expressions and returns true only if both expressions evaluate as true. The AND operator returns false if one of the two expressions evaluates to false.
 

Syntax:

Here is the syntax of the AND operator:

expression1 AND expression_2

 

 

Example:

The following query uses the AND operator to find customers located in Boston whose age is greater than 20:

SELECT * FROM Customers WHERE Address = 'Boston' AND Age > 20;

Output:

+----------+-----------+--------+-----------------------+
|    ID    |    Name   |  age   |     Address           |
+----------+-----------+--------+-----------------------+
|    103   |   Jean    |   35   | Boston                |
|    104   |   Bob     |   40   | Boston                |
+----------+-----------+--------+-----------------------+
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *