This tutorial explains how to use the MySQL BIN function with syntax and examples.
The MySQL BIN function converts a decimal number to a binary number and returns the result as a string value.
The syntax for the BIN function in MySQL is:
BIN( number )
The number to convert to a binary representation.
The BIN function can be used in the following versions of MySQL:
Let's look at some MySQL BIN function examples and explore how to use the BIN function in MySQL.
For example:
mysql> SELECT BIN(5);
Output: '101'
mysql> SELECT BIN(6);
Output: '110'
mysql> SELECT BIN(99);
Output: '1100011'