What is BIN() in SQL?

The BIN() function returns a binary representation of the decimal value, given as a parameter, in the form of a string.

Figure 1 shows a visual representation of the BIN() function.

Figure 1: Visual representation of BIN() function

Syntax

BIN(value)

Parameter

The BIN() function takes the decimal value as a parameter.

Return value

The BIN() function returns a binary representation of the decimal value sent as a parameter in the string form.

It returns NULL if the decimal value is NULL.

Example

-- simple number
SELECT BIN(11);
SELECT BIN(100);
-- NULL
SELECT BIN(NULL);

Free Resources