###COLLATION_SORT_KEY
Description
The COLLATION_SORT_KEY function generates a sort key for the input string based on the specified character set, which is used to sort the string according to the rules of the particular character set.
Syntax
- str: The input string.
- coll: The specified character set.
Return Value
Returns a binary value representing the sort key generated for the input string according to the specified character set.
Example
- Sort Chinese strings according to pinyin order:
The result is as follows:
- Sort English strings according to the English character set:
The result is as follows:
Notes
- The COLLATION_SORT_KEY function is only applicable to string type inputs.
- The input character set must be valid, otherwise NULL will be returned.
- The generated sort key is a binary value that can be used for sorting in the ORDER BY clause.