Forum : Difference between CHAR_LENGTH and LENGTH...
Brief description  about Online courses   join in Online courses
View Sheetal  Panday 's Profile

Difference between CHAR_LENGTH and LENGTH...

CHAR_LENGTH and LENGTH differences in MySQL...
Asked by Sheetal Panday | Nov 9, 2009 |  Reply now
Replies (2)
View manju s-reddy 's Profile
We r testing both function and tried to generate different results for both.
Here is what v did:

mysql> select length(CONVERT('hallo' USING sjis) ) length, char_length(CONVERT('hallo' USING sjis)) char_length ;
+--------+-------------+
| length | char_length |
+--------+-------------+
| 5 | 5 |
+--------+-------------+
1 row in set (0.01 sec)

because LENGHT should give the length in bytes why are both results the same ?
Feb 17, 2010
View teacher siliconindia 's Profile
Hi Sheetal,

The first is, naturally, the character count. The second is byte count. For the Latin characters the numbers are the same, but they are not the same for Unicode and other encodings.
Nov 9, 2009