I’m trying to create a mysql query for all elements starting with some user picked croatian alphabet letter.
It all works fine for regular latin letters.
The problem I’m facing is that when i search something with S and say Š, I get both elements starting with S and Š, same goes for ČĆC.
$sql=" SELECT * FROM `default_subjects` where name like '{$keywords}%'";
Collation set is utf8_unicode_ci.
Thanks. 🙂
“S” and “Š” are treated as the same letter due to the collation rules. This is supposed to be a good thing usually, as it allows “fuzzy” searches to a degree. If you do not want this and want only identical letters to be identical, change the collation to
utf8_bin(binary collation). You can do this as a general setting for the table/column, or for each query as needed, depending on how often you need either functionality. See http://dev.mysql.com/doc/refman/5.1/en/charset-collate.html for the syntax.