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.
OCTET_LENGTH( str )
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.
It returns the length of given string.
Applying OCTET_LENGTH() Function to a string.
SELECT OCTET_LENGTH('geeksforgeeks') as String_Length;
Applying OCTET_LENGTH() Function to a number string.
SELECT OCTET_LENGTH(56432) as Length;
Applying OCTET_LENGTH() Function to a column in a table.
Table – Student_Details
Finding total length of name of every student(includes one space).
SELECT OCTET_LENGTH(Student_Name) as Name_Length FROM Student_Details ;
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- MySQL | Common MySQL Queries
- MySQL | LEAD() and LAG() Function
- MySQL | BIN() Function
- MySQL | LAST_DAY() Function
- WEEKOFYEAR() Function in MySQL
- MOD() Function in MySQL
- MySQL | Creating stored function
- MySQL | Group_CONCAT() Function
- MySQL | DEFAULT() Function
- MySQL | AES_ENCRYPT ( ) Function
- MySQL | AES_DECRYPT ( ) Function
- MySQL | MD5 Function
- MySQL | COMPRESS( ) Function
- MySQL | PASSWORD Function
- MySQL | OLD_PASSWORD Function
- MySQL | DES_DECRYPT ( ) Function
- MySQL | DES_ENCRYPT ( ) Function
- MySQL | DECODE( ) Function
- MySQL | ENCODE( ) Function
- MySQL | SHA1( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.