Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

MySQL BIT_LENGTH Function

by suresh

The MySQL BIT_LENGTH is one of the String Function, which returns the length of a specified string in bits. The syntax of the BIT_LENGTH Function in MySQL is as shown below:

SELECT BIT_LENGTH (Character_Expression)
FROM [Source]

To demonstrate this string BIT_LENGTH in MySQL, we are going to use the customer details table data that we showed below

MySQL String BIT_LENGTH Function Example

MySQL BIT_LENGTH Example 1

The String BIT_LENGTH in MySQL returns the Bit length of a given character expression. The following BIT_LENGTH query shows multiple ways to use this function by using different values.

SELECT BIT_LENGTH('A');

SELECT BIT_LENGTH('Tutorial Gateway');

-- It returns NULL as output
SELECT BIT_LENGTH(NULL);

SELECT BIT_LENGTH(12);
MySQL BIT_LENGTH Function Example 1

MySQL BIT_LENGTH Example 2

In this String Function example, we are going to implement the string BIT_LENGTH function in MySQL on different columns in a customer details table. The following MySQL statement returns the Bit length of the data present in First_Name, Last_Name, and Education Columns.

-- MySQL String BIT_LENGTH Example
USE company;
SELECT  First_Name, 
		BIT_LENGTH(First_Name) AS FName_Length,
		Last_Name,
        BIT_LENGTH(Last_Name) AS LName_Length,
        Education, 
        BIT_LENGTH(Education) AS Edu_Length,
        Profession, 
        Yearly_Income,     
        Sales
FROM customerdetails;
MySQL BIT_LENGTH Function Example 2

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy