char_length()和character_length()之间有什么区别?

huangapple go评论66阅读模式
英文:

What is the difference between char_length() and character_length()

问题

使用这两个函数我得到了相同的结果。这两个函数有什么不同之处,还是它们只是彼此的别名?

  • 使用 char_length(first_name) 函数的结果:

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

  • 使用 character_length(first_name) 函数的结果:

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

英文:

I get the same result using both functions. How these two functions are different from each other or they are just alias of each other

select char_length(first_name) from employee;

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

select character_length(first_name) from employee;

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

答案1

得分: 2

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

CHARACTER_LENGTH()CHAR_LENGTH() 的同义词。

英文:

MySQL CHARACTER_LENGTH() returns the length of a given string. The length is measured in characters.

The CHARACTER_LENGTH() is the synonym of CHAR_LENGTH().

答案2

得分: 1

MYSQL官方文档表示 CHAR_LENGTH() 返回参数中的字符数,而 CHARACTER_LENGTH()CHAR_LENGTH() 的同义词。

链接:https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char-length

英文:

MYSQL official documentation says CHAR_LENGTH() returns the number of characters in the argument and CHARACTER_LENGTH() is a synonym of CHAR_LENGTH()

https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char-length

答案3

得分: 1

CHAR_LENGTH()函数返回其参数中的字符数。

您也可以使用CHARACTER_LENGTH()函数,因为它执行相同的操作。

SELECT FirstName,
LastName,
DepartmentName,
CHAR_LENGTH(DepartmentName) AS 部门字符长度,
Email,
CHARACTER_LENGTH(Email) AS 电子邮件字符长度
FROM employe
WHERE CHAR_LENGTH(DepartmentName) > 7
ORDER BY 部门字符长度;

英文:

The CHAR_LENGTH() function returns the number of characters in its argument.

You can also use the CHARACTER_LENGTH() function, as it does the same thing.

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`;

答案4

得分: -1

Both are CHARACTER_LENGTH and CHAR_LENGTH Functions are same. You could visit to this site:
w3schools

英文:

Both are CHARACTER_LENGTH and CHAR_LENGTH Functions are same. You could visit to this site:
w3schools

huangapple
  • 本文由 发表于 2020年1月3日 14:07:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/59573929.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定