MySQL BIT_LENGTH() function is used for which purpose?



Forgetting the length of the string in bits, MySQL BIT_LENGTH() string function can be used. Its syntax is 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('tutorialspoint');
+------------------------------+
| BIT_LENGTH('tutorialspoint') |
+------------------------------+
|                          112 |
+------------------------------+
1 row in set (0.00 sec)

mysql> Select BIT_LENGTH(2365489);
+---------------------+
| BIT_LENGTH(2365489) |
+---------------------+
|                  56 |
+---------------------+
1 row in set (0.00 sec)

Advertisements