MySQL BIN() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL BIN() Function

❮ MySQL Functions

Example

Convert a decimal number to a binary number:

SELECT BIN(15);
Try it Yourself »

Definition and Usage

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

Syntax

BIN(number)

Parameter Values

Parameter Description
number Required. The number to convert

Note

  • BIN() is equivalent to using CONV() with CONV(number, 10, 2) syntax

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Convert a decimal number to a binary number:

SELECT BIN(111);
Try it Yourself »

Example

Convert a decimal number to a binary number:

SELECT BIN(8);
Try it Yourself »

❮ MySQL Functions