How the WEIGHT_STRING() Function Works in MySQL

In MySQL, the WEIGHT_STRING() function returns the weight string for the input string. The return value is a binary string that represents the comparison and sorting value of the string.

If the input string is a nonbinary value, the return value contains the collation weights for the string. If it’s a binary value, the result is the same as the input string. This is because the weight for each byte in a binary string is the byte value.

This function is a debugging function intended for internal use. It can be used for testing and debugging of collations. Note that its behavior can change between MySQL versions.

Continue reading

How the UNHEX() Function Works in MySQL

In MySQL, the UNHEX() function allows you to “unhex” a string in MySQL. In other words, it allows you to convert a hexadecimal value to a human-readable string.

Specifically, the function interprets each pair of characters in the argument as a hexadecimal number and converts it to the byte represented by the number. The return value is a binary string.

Continue reading

How the MAKE_SET() Function Works in MySQL

In MySQL, the MAKE_SET() function returns a set value (a string containing substrings separated by , characters) consisting of the characters specified as arguments when you call the function.

When you call the function, you specify any number of strings (separated by a comma), as well as one or more bit values that determine which strings to return in the set value.

Continue reading