Enter Characters as BINARY Number in MySQL Statement



Following are the two approaches with the help of which we can enter characters as a BINARY number −

By prefix ‘B’

In this approach we need to quote binary numbers within single quotes with a prefix of B. Then BINARY number string will be automatically converted into a character string.

Example

mysql> Select B'01000001';
+-------------+
| B'01000001' |
+-------------+
| A           |
+-------------+
1 row in set (0.00 sec)

By prefix 0b

In this approach, we need to write BINARY numbers without any quotes with a prefix of 0b. Then BINARY number string will be automatically converted into a character string.

Example

mysql> Select 0b01000001;
+------------+
| 0b01000001 |
+------------+
| A          |
+------------+
1 row in set (0.00 sec)
Updated on: 2020-06-22T12:22:22+05:30

174 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements