MySQL Function to Determine String Length in Bits



MySQL BIT_LENGTH() string function is used to get the length of the string in bits.

Syntax

BIT_LENGTH(Str)

Here Str, the argument of BIT_LENGTH() function, is the string whose BIT_LENGTH value is to be retrieved. Str can be a character string or number string. If it is a character string then it must be in quotes.

Example

mysql> Select BIT_LENGTH('New Delhi');

+-------------------------+
| BIT_LENGTH('New Delhi') |
+-------------------------+
| 72                      |
+-------------------------+

1 row in set (0.00 sec)

mysql> select BIT_LENGTH(123456);

+--------------------+
| BIT_LENGTH(123456) |
+--------------------+
| 48                 |
+--------------------+

1 row in set (0.00 sec)
Updated on: 2020-06-20T08:17:21+05:30

97 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements