In this article, we will show you, How to write MySQL String OCTET_LENGTH Function query using Command Prompt, and Workbench with an example.
MySQL OCTET_LENGTH Syntax
The basic syntax of OCTET_LENGTH of a string in MySQL is as shown below:
SELECT OCTET_LENGTH(String_Expression) FROM Source
MySQL OCTET_LENGTH Example 1
The MySQL string OCTET LENGTH function counts and returns the number of characters inside a given expression. The following query shows multiple ways to use this lOCTET_LENGTH function.
SELECT OCTET_LENGTH('Tutorial Gateway');
SELECT OCTET_LENGTH('MySQL Tutorial');
Remember, OCTET_LENGTH function counts the empty space as well.
MySQL OCTET_LENGTH Example 2
Here, we are using this function on a table. In this example, we are going to find the Octet length of Department Name column and Email column.
OCTET_LENGTH(DepartmentName) AS DeptLen,
OCTET_LENGTH(Email) AS EmailLen
FROM `MySQL Tutorial`.employe;
Thank You for Visiting Our Blog