Categories:

Conditional Expression Functions

BOOLXOR

Computes the Boolean XOR of two numeric expressions (i.e. one of the expressions, but not both expressions, is TRUE). 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 one expression is non-zero and the other expression is zero.

  • False if both expressions are non-zero or both expressions are zero.

  • NULL if one or both expressions are NULL.

See also:

BOOLAND , BOOLNOT , BOOLOR

Syntax

BOOLXOR( expr1 , expr2 )

Examples

SELECT BOOLXOR(2, 0), BOOLXOR(1, -1), BOOLXOR(0, 0), BOOLXOR(NULL, 3), BOOLXOR(NULL, 0), BOOLXOR(NULL, NULL);

+---------------+----------------+---------------+------------------+------------------+---------------------+
| BOOLXOR(2, 0) | BOOLXOR(1, -1) | BOOLXOR(0, 0) | BOOLXOR(NULL, 3) | BOOLXOR(NULL, 0) | BOOLXOR(NULL, NULL) |
|---------------+----------------+---------------+------------------+------------------+---------------------|
| True          | False          | False         | NULL             | NULL             | NULL                |
+---------------+----------------+---------------+------------------+------------------+---------------------+