When BIT_LENGTH() function is applied to column/s of MySQL table then it will return the number of bits of the strings that are stored in the column/s of a table. Following example will demonstrate it.
Suppose from a table ‘Student’ we want to find the length of strings stored in column ‘Name’ and ‘Address’, then we can write following query −
mysql> Select Name, Address, BIT_LENGTH(Name) As 'Name in Bits', BIT_LENGTH(Address) AS 'Address in Bits' from Student; +---------+---------+--------------+-----------------+ | Name | Address | Name in Bits | Address in Bits | +---------+---------+--------------+-----------------+ | Gaurav | Delhi | 48 | 40 | | Aarav | Mumbai | 40 | 48 | | Harshit | Delhi | 56 | 40 | | Gaurav | Jaipur | 48 | 48 | +---------+---------+--------------+-----------------+ 4 rows in set (0.00 sec)