mariadb char_length()和character_length()的区别是什么?

eit6fx6z  于 12个月前  发布在  其他
关注(0)|答案(4)|浏览(221)

我使用两个函数得到相同的结果。这两个函数是如何彼此不同的,或者它们只是彼此的别名
从employee中选择char_length(first_name);

+-------------------------+
| char_length(first_name) |
+-------------------------+
|                       5 |
|                       3 |
|                       7 |
|                       6 |
|                       5 |
|                       7 |
|                       4 |
|                       4 |
|                       3 |
|                       5 |
|                       5 |
+-------------------------+

字符串
从employee中选择character_length(first_name);

+------------------------------+
| character_length(first_name) |
+------------------------------+
|                            5 |
|                            3 |
|                            7 |
|                            6 |
|                            5 |
|                            7 |
|                            4 |
|                            4 |
|                            3 |
|                            5 |
|                            5 |
+------------------------------+

odopli94

odopli941#

MySQL CHARACTER_LENGTH()返回给定字符串的长度。长度以字符为单位。
CHARACTER_LENGTH()CHAR_LENGTH()的同义词。

kmbjn2e3

kmbjn2e32#

MYSQL官方文档说CHAR_LENGTH()返回参数中的字符数,CHARACTER_LENGTH()CHAR_LENGTH()的同义词
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char-length

brgchamk

brgchamk3#

函数的作用是:返回参数中的字符数。
您也可以使用CHARACTER_LENGTH()函数,因为它做同样的事情。

SELECT  FirstName, 
    LastName, 
    DepartmentName, 
    CHAR_LENGTH(DepartmentName) AS `Char Length of Dept`,
    Email,
    CHARACTER_LENGTH(Email) AS `Char Length of Email`
    FROM employe
    WHERE CHAR_LENGTH(DepartmentName) > 7
    ORDER BY `Char Length of Dept`;

字符串

t9aqgxwy

t9aqgxwy4#

两者都是CHARACTER_LENGTH和CHAR_LENGTH函数是相同的。您可以访问这个网站:w3schools

相关问题