- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we apply BIT_LENGTH() function on the column/s of MySQL table?
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.
Example
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)
Advertisements