# Which function in MySQL returns the same output as BIN() function?

MySQLMySQLi Database

As we know that BIN() function returns the binary string of a number, of the DECIMAL base, after converting it into a binary value. In this way, it can be considered same as CONV(N,10,2) function. It means the output of CONV(N,10,2) would be same as the output of BIN() function.

In CONV(N,10,2) function, ‘N’ is the number which will be converted, 10 represents the base, i.e. DECIMAL, of N and 2 represents that we want to convert N into a binary string.

## Example

The example below will demonstrate that the output return by BIN() is same as CONV(N,10,2)

mysql> Select BIN(15);
+---------+
| BIN(15) |
+---------+
| 1111    |
+---------+
1 row in set (0.00 sec)

mysql> Select CONV(15,10,2);
+---------------+
| CONV(15,10,2) |
+---------------+
| 1111          |
+---------------+
1 row in set (0.00 sec)
Updated on 20-Jun-2020 08:11:07