What is the function of the MySQL length function?

The LENGTH function in MySQL is used to return the number of characters in a specified string. It can be used to calculate the length of a string or the length of each value in a column.

syntax:
LENGTH(str)

Explanation of parameters:

  1. str: the string or column name for which to calculate the length.

Return value:

  1. Return the number of characters in the string. If the string is NULL, return NULL.

For example, when you run the query SELECT LENGTH(‘Hello World’); the result will be 11.

The result of SELECT LENGTH(‘你好世界’); is 5.

bannerAds