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

mysql char_length()获取字符串长度

WBOY
Release: 2016-06-01 09:56:51
Original
1021 people have browsed it

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

例如:

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

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

结果为:2</code>
Copy after login

 

 

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

<code>select char_length('my'); 

结果为:2</code>
Copy after login

 

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

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

结果为:2</code>
Copy after login

 

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

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

结果为:2</code>
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template