The length of the argument may be returned by this function. There are two arguments for the return value, one for the STRING argument and another for the BYTES argument. The length of the string in characters is equal to the length of the string in chars.
If you think so, BYTES_LENGTH is exactly the same as before, but in numbers of bytes instead of characters. The original order ID should have all three functions applied to it.
SELECT order_id, CHAR_LENGTH(order_id) AS order_id_CHAR, CHARACTER_LENGTH(order_id) AS order_id_CHARACTER, BYTE_LENGTH(order_id) AS order_id_BYTE FROM `orders.orders`;
The function must be called and the column name must be written.
The functions CHAR_LENGTH() and CHARACTER_LENGTH() both return the same result. As I have mentioned, BYTE_LENGTH() measures the length in bytes. The length in bytes is different from the character length if there are Unicode characters. That’s why it shows a length of 20 bytes in the fourth row. The character “ć“, a Unicode character, somehow got into the order ID.