MYSQL Tutorial


OCTET_LENGTH() function

MySQL OCTET_LENGTH() returns the length (in characters) of a string.




Name Description
str A string whose length is to be returned.

The above function is a synonym for LENGTH().

Syntax Diagram:

MySQL OCTET_LENGTH() Function - Syntax Diagram

MySQL Version: 5.6

Video Presentation

Example: MySQL OCTET_LENGTH() function

The following MySQL statement will return the length of the string w3resource. The return value is 10.


SELECT OCTET_LENGTH("w3resource");

Sample Output:

mysql> SELECT OCTET_LENGTH("w3resource");
| OCTET_LENGTH("w3resource") |
|                         10 | 
1 row in set (0.00 sec)

All String Functions

MySQL String Functions, slide presentation

Many of our valued users post comments along with piece of code. Disqus may, false positively, consider those piece of code as Bad or Starnge syntax and send those comments to spam automatically. Even if that happens, we will make sure those useful comments are taken out of spam and approved. It may take a couple of days for that though, but any useful comment will be brought to public view for sure. We regret if that happend to any user. You may write us directly regarding this to - w3resource[at]yahoo[dot]com.