BIT_XOR()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns the bitwise exclusive-or operation across a set of numbers.
USAGE
BIT_XOR(number)
Argument Name | Description |
---|---|
| The number to exclusive "or" into the aggregated value |
DETAILS
BIT_XOR()
is an aggregate function that returns the bitwise exclusive "or" of a set of values.
The calculation is done with 64-bit (BIGINT
) precision.
A string input value is parsed into an integer, with the digits at the start of the string being significant. If there are no leading digits, it is processed as a 0
value.
A NULL
input value is ignored, having no effect on the result.
If no numeric values are in the input set, a 0
is returned.
EXAMPLES
CREATE TABLE bit_and_example (
item VARCHAR(20),
val INT
);
INSERT INTO bit_and_example VALUES
('Foo', 242),
('Bar', 101),
('Baz', 99),
('Foo', 113),
('Bar', 64),
('Baz', 86);
SELECT BIT_XOR(val)
FROM bit_and_example;
+--------------+
| BIT_XOR(val) |
+--------------+
| 147 |
+--------------+
SELECT item, BIT_XOR(val)
FROM bit_and_example
GROUP BY item
ORDER BY item;
+------+--------------+
| item | BIT_XOR(val) |
+------+--------------+
| Bar | 37 |
| Baz | 53 |
| Foo | 131 |
+------+--------------+