Categories:

Conditional expression functions

BOOLAND

Computes the Boolean AND of two numeric expressions. In accordance with Boolean semantics:

  • Non-zero values (including negative numbers) are regarded as True.

  • Zero values are regarded as False.

As a result, the function returns:

  • True if both expressions are non-zero.

  • False if both expressions are zero or one expression is zero and the other expression is non-zero or NULL.

  • NULL if both expressions are NULL or one expression is NULL and the other expression is non-zero.

See also:

BOOLNOT , BOOLOR , BOOLXOR

Syntax

BOOLAND( expr1 , expr2 )
Copy

Examples

SELECT BOOLAND(1, -2), BOOLAND(0, 2.35), BOOLAND(0, 0), BOOLAND(0, NULL), BOOLAND(NULL, 3), BOOLAND(NULL, NULL);

+----------------+------------------+---------------+------------------+------------------+---------------------+
| BOOLAND(1, -2) | BOOLAND(0, 2.35) | BOOLAND(0, 0) | BOOLAND(0, NULL) | BOOLAND(NULL, 3) | BOOLAND(NULL, NULL) |
|----------------+------------------+---------------+------------------+------------------+---------------------|
| True           | False            | False         | False            | NULL             | NULL                |
+----------------+------------------+---------------+------------------+------------------+---------------------+
Copy
Language: English