For the complete documentation index, see llms.txt. This page is also available as Markdown.

XOR

Logical exclusive OR. XOR returns 1 if an odd number of operands is non-zero, 0 otherwise, and NULL if any operand is NULL.

Syntax

XOR

Description

XOR stands for eXclusive OR. Returns NULL if either operand is NULL. For non-NULL operands, evaluates to 1 if an odd number of operands is non-zero, otherwise 0 is returned.

Examples

SELECT 1 XOR 1;
+---------+
| 1 XOR 1 |
+---------+
|       0 |
+---------+

SELECT 1 XOR 0;
+---------+
| 1 XOR 0 |
+---------+
|       1 |
+---------+

SELECT 1 XOR NULL;
+------------+
| 1 XOR NULL |
+------------+
|       NULL |
+------------+

XOR is evaluated from left to right. In the following example, the left 1 XOR 1 is evaluated first, and returns 0. Then, 0 XOR 1 is evaluated, and 1 is returned.

See Also

This page is licensed: GPLv2, originally from fill_help_tables.sql

spinner

Last updated

Was this helpful?