Open In App

OCTET_LENGTH() Function in MySQL

Last Updated : 24 Sep, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
In this article, we are going to cover the OCTET_LENGTH function. And will see syntax and example of OCTET_LENGTH function. Let's discuss one by one. OCTET_LENGTH function in MySQL is used to returns the number of characters in a given string.

Syntax :
OCTET_LENGTH( str )
Parameter : This function accepts one parameter as mentioned above in the syntax and described below in the example.
  • str : Given string whose number of characters is to be find.
Returns - It returns the length of given string. Example-1 : Applying OCTET_LENGTH() Function to a string.
SELECT OCTET_LENGTH('geeksforgeeks') 
as String_Length;
Output :
String_Length
13
Example-2 : Applying OCTET_LENGTH() Function to a number string.
SELECT OCTET_LENGTH(56432) 
as Length;
Output :
Length
5
Example-3 : Applying OCTET_LENGTH() Function to a  column in a table. Table - Student_Details
Student_IdStudent_Name
134500Amit Singh
134501Arunima Rao
134502Shreya Sharma
134503Leena Mondal
Finding total length of name of every student(includes one space).
SELECT OCTET_LENGTH(Student_Name) as Name_Length 
FROM Student_Details ;
Output :
Name_Length
10
11
13
12

Next Article
Article Tags :

Similar Reads