Tuesday, August 11, 2015

what is diff. between LENGTH() and CHAR_LENGTH() in Mysql or Sql

LENGTH() it will return the length of the string which measured in bytes.
CHAR_LENGTH() it will return the length of the string which measured in characters.

select LENGTH(_utf8 '€'), CHAR_LENGTH(_utf8 '€');

+---------------------+--------------------------+
| LENGTH(_utf8 '€')   | CHAR_LENGTH(_utf8 '€')   |
+---------------------+--------------------------+
|                   3 |                        1 |
+---------------------+--------------------------+