Which MySQL function can be used to find out the length of the string 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: 20-Jun-2020

67 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements