The concept of comparing and arranging characters in a database is called matching .
How strings are stored depends on the mapping that is usually set in the properties of a server, client, or session.
In MySQL :
SELECT * FROM ( SELECT 'a' AS str UNION ALL SELECT 'A' AS str UNION ALL SELECT 'b' AS str UNION ALL SELECT 'B' AS str ) q ORDER BY str COLLATE UTF8_BIN
and
SELECT * FROM ( SELECT 'a' AS str UNION ALL SELECT 'A' AS str UNION ALL SELECT 'b' AS str UNION ALL SELECT 'B' AS str ) q ORDER BY str COLLATE UTF8_GENERAL_CI
UTF8_BIN sorts characters according to their Unicode. Caps have lower Unicode and therefore go first.
UTF8_GENERAL_CI sorts characters according to their alphabetical position, not counting the case.
Comparing indexes is also important for indexes, since indexes are highly dependent on sorting and comparison rules.
source share