Home >Database >Mysql Tutorial >mysql char_length()获取字符串长度

mysql char_length()获取字符串长度

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 09:56:511060browse

mysql char_length()获取字符串长度,需要注意的是,不管汉字还是数字或者是字母或其他文字都算是一个字符,这个与mysql length()函数有区别。

例如:

1.用char_length()获取中文字符的长度:

<code class="language-sql">select char_length('中国'); 

结果为:2</code>

 

 

2.用char_length()获取英文字符的长度:

<code>select char_length('my'); 

结果为:2</code>

 

3.用char_length()获取含有中文和英文字符的长度:

<code>select char_length('m我'); 

结果为:2</code>

 

4.用char_length()获取日文字符的长度

<code>select char_length('にほ'); 

结果为:2</code>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn