MySQL: BIN Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL BIN Function

In this guide, we will explain how to use the MySQL BIN function with syntax and examples.

Description

The MySQL BIN function converts a decimal number to a binary number and returns the result as a string value.

Syntax

The syntax for the BIN function is:

BIN( number )

Parameters or Arguments

number

The number to convert to a binary representation.

Note

  • The BIN function returns the binary representation as a string value.
  • The BIN function is equivalent to using the CONV function with CONV(number,10,2) syntax.

Applies To

The BIN function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some BIN function examples and explore how to use the BIN function.

For example:

mysql> SELECT BIN(5);
Result: '101'

mysql> SELECT BIN(6);
Result: '110'

mysql> SELECT BIN(99);
Result: '1100011'

Next Topic : Click Here

This Post Has One Comment

Leave a Reply