英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论