MySQL BIN() Functions – String Functions
MySQL BIN() Functions: Syntax
MySQL BIN() Functions: Description
BIN() function return a string containing binary representation of a number.
Returns a string representation of the binary value of N, where N is a longlong ( BIGINT ) number. This is equivalent to CONV(N,10,2).
MySQL BIN() Functions: Parameter
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|lef|lef|left”]
Name, Required /Optional, Value Type, Description
number, Required, Number , It should be number. returns 0 if string is passed.
[/table]
MySQL BIN() Functions: Output
[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Returns,
NULL, if N is NULL.
Binary code, if N is number.
0, if N is a string.
[/table]
MySQL BIN() Functions: Example 1 :
SELECT BIN(null);
mysql> SELECT BIN(10);
+———+
| BIN(10) |
+———+
| 1010 |
+———+
1 row in set (0.00 sec)
mysql> SELECT BIN(NULL);
+———–+
| BIN(NULL) |
+———–+
| NULL |
+———–+
1 row in set (0.00 sec)
mysql> SELECT BIN(‘autu’);
+————-+
| BIN(‘autu’) |
+————-+
| 0 |
+————-+
1 row in set (0.00 sec)
Below is the mysql terminal screen for above code :
See all MySQL String functions MySQL 8 String Functions.