MySQL AND operator
Description
MySQL logical AND operator compares two expressions and returns true if both of the expressions are true.
This operator returns 1 if all operands are nonzero and not NULL, 0 if one or more operands are 0, otherwise NULL is returned.
Example
Code
SELECT 5 && 5;
Explanation
In the above MySQL statement all the operands are non zero (5 and 5) and both of them are not NULL, so logical and operator returns 1.
Output

Example of MySQL AND operator with zero input
Code
SELECT 5 && 0;
Explanation
In the above MySQL statement one of the operands is non zero (5 and 0), so logical and operator returns 0.
Output

Example of MySQL AND operator with NULL input
Code
SELECT 5 && NULL;
Explanation
In the above MySQL statement one of the operands is non zero (5) and another one is NULL, so logical and operator returns NULL.
Output

Example of MySQL AND operator with zero and NULL input
Code
SELECT 0 && NULL;
Explanation
In the above MySQL statement one of the operands is zero (0) and another one is NULL, so logical and operator returns 0.
Output

Example of MySQL AND operator with both inputs are NULL
Code
SELECT NULL && NULL;
Explanation
In the above MySQL statement all the operands are NULL. So the operator returns NULL.
Output


