|
Description
Bitwise OR.
The result type depends on whether the arguments are evaluated as binary strings or numbers:
- Binary-string evaluation occurs when the arguments have a binary string type, and at least one of them is not a hexadecimal literal, bit literal, or
NULLliteral. Numeric evaluation occurs otherwise, with argument conversion to unsigned 64-bit integers as necessary. - Binary-string evaluation produces a binary string of the same length as the arguments. If the arguments have unequal lengths, an
ER_INVALID_BITWISE_OPERANDS_SIZEerror occurs. Numeric evaluation produces an unsigned 64-bit integer.
Syntax
1. > SELECT value1 | value2;
Examples
1. mysql> SELECT 29 | 15;
2. +---------+
3. | 29 | 15 |
4. +---------+
5. | 31 |
6. +---------+
7. 1 row in set (0.01 sec)
9. mysql> select null | 2;
10. +----------+
11. | null | 2 |
12. +----------+
13. | NULL |
14. +----------+
15. 1 row in set (0.01 sec)
17. mysql> select null | 2;
18. +----------+
19. | null | 2 |
20. +----------+
21. | NULL |
22. +----------+
23. 1 row in set (0.01 sec)
25. create table t1(a int, b int unsigned);
26. insert into t1 values (-1, 1), (-5, 5);
28. mysql> select a | 2, b | 2 from t1;
29. +-------+-------+
30. | a | 2 | b | 2 |
31. +-------+-------+
32. | -1 | 3 |
33. | -5 | 7 |
34. +-------+-------+
