mysqlutf-8utf8mb4

SELECT Hüsby returns the 'wrong' output Husby


In the same database, I run the query and get one correct and one incorrect result.

correct

SELECT Ort FROM `stammdaten` WHERE `Ort` = 'Husby';
    
Ort 
Husby   
Husby   

wrong

SELECT Ort FROM stammdaten WHERE Ort = 'Hüsby';

Ort
Husby
Husby

database : utf8mb4_unicode_ci

table : utf8mb4_unicode_ci

field : utf8mb4_unicode_ci

Does anyone have any ideas what else I can change or check?


Solution

  • You can check the documentation, because everything works as expected:

    Unicode needs to be understood (ü versus ), case insensitivity rules need to be understood (ß versus SS), and accent insensitivity need to be understood (Café versus cafè). Otherwise you end up having data stored which you are unable to properly find or filter by because you chose the wrong collation. Understanding the sorting is also an aspect (does ü sort after u or after ö?), although rarily of interest.