Home / Definitions / AND Operator

AND Operator

Webopedia Staff
Last Updated June 25, 2022 12:13 am

The AND operator is a logical operator, or Boolean operator, that evaluates to TRUE if all of its operands are true and FALSE otherwise. It is represented by the symbol && in most programming languages, although it can be written as & in some languages such as C++.

Example of AND Operator in MySQL

The AND operator is used to combine two or more conditions in an expression. For example, the following query uses the AND operator to find all products that have both red and green as their colors.

SELECT * FROM Products WHERE Color = 'Red' AND Color = 'Green'; 

In this case, we are using the same column for both conditions (Color). However, you can also use different columns for each condition by separating them with commas. For example, if we wanted to find all products with a price greater than $10 but less than $20, then we could write our query like this:

SELECT * FROM Products WHERE Price > 10 AND Price < 20;

Read next: The Best Programming Languages to Learn