I have some MySQL table with column 'title' which type is varchar(255)
, character set is utf8mb4 and collation is utf8mb4_general_ci.
Lets say I have few records with title and those titles contain (or not) diactrics:
id | title
-----------
1 | zolc
2 | żółć
3 | żołc
4 | zólć
I can correctly insert those diactrics and also they are properly displayed when table is selected. But when I try something like this:
SELECT *
FROM my_table
WHERE title LIKE "%zolc%";
I got:
id | title
-----------
1 | zolc
4 | zólć
As you see I asked for version without any diactricts, but also got row with id 4. Selecting żółć
returns rows with ids 2 (as expected) and 3. Querying for zołć
returns rows 2 and 3, where I would expect that nothing will be returned. There is many combination like this, where some "wrong" rows are returned after query (I tried also with ą
and ę
and they also act strange).
At first I thought that it is problem with configuration of my technological stack (java web application on top of Spring Boot) but I got exactly the same results when executing queries from MySQL Workbench on local db on Windows machine and by executing queries by ssh to remote db running on Ubuntu machine. There is also no difference if query is done using title LIKE "value"
or with WHERE title = "value"
.
I couldn't find explanation for this - note that this does not simply returns all rows that "match" query parameter but without special characters. I'm struggling to enable search by title but I would like to it be 1:1, so when I use "ż" in my query parameter only rows where "ż" is actually present will be returned.
Thanks in advance for any help.