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

mysql char_length()获取字符串长度

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 09:56:51
Original
1039 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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template