Reputation: 3578
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 |
+------------------------------+
Upvotes: 2
Views: 1769
Reputation: 1
Both are CHARACTER_LENGTH and CHAR_LENGTH Functions are same. You could visit to this site: w3schools
Upvotes: -1
Reputation: 37
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`;
Upvotes: 1
Reputation: 13080
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
Upvotes: 1
Reputation: 13394
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()
.
Upvotes: 2