8

My Table collation is "utf8_general_ci". If i run a query like:

SELECT * FROM mytable WHERE myfield = "FÖÖ"

i get results where:

...  myfield = "FÖÖ"
...  myfield = "FOO"

is this the default for "utf8_general_ci"?

What collation should i use to only get records where myfield = "FÖÖ"?

Daniel
  • 10,641
  • 12
  • 47
  • 85
  • 1
    possible duplicate of [MySQL treats ÅÄÖ as AAO?!](http://stackoverflow.com/questions/2607130/mysql-treats-aao-as-aao) – Pekka Jun 08 '11 at 13:24

3 Answers3

7
SELECT * FROM table WHERE some_field LIKE ('%ö%'  COLLATE utf8_bin)
Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
Gunni
  • 519
  • 5
  • 14
  • 2
    When providing code that solves the problem, it is best to also give at least a short explanation of how it works so that folks reading won't have to mentally parse it line by line to understand the differences. – Fluffeh Sep 28 '12 at 08:18
  • 3
    the answer came from mr satan, he does not need to explain. – MilMike Jul 04 '14 at 13:58
  • 2
    ERROR 1253 (42000): COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4' – donquixote Sep 15 '17 at 00:37
3

A list of the collations offered by MySQL for Unicode character sets can be found here:

http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html

If you want to go all-out and require strings to be absolutely identical in order to test as equal, you can use utf8_bin (the binary collation). Otherwise, you may need to do some experimentation with the different collations on offer.

Hammerite
  • 21,755
  • 6
  • 70
  • 91
0

For scandinavian letters you can use utf8_swedish_ci fir example.

Here is the character grouping for utf8_swedish_ci. It shows which characters are interpreted as the same. http://collation-charts.org/mysql60/mysql604.utf8_swedish_ci.html

Here's the directory listing for other collations. I'm no sure which is the used utf8_general_ci though. http://collation-charts.org/mysql60/

jiv-e
  • 483
  • 6
  • 8