0

I have a mysql table with hungarian words, so accents are expected. This column full of words must be a UNIQUE one, so I need a charset which treats e.g.: "a" and "á" different.

I read on forums, that my best choise for character collision is utf8_unicode_ci. So my create database command looks like this:

CREATE DATABASE db_name CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci;

After testing is with "mar" - "már" and (with a german word, more popular language) "straße" - "strasse", it still doesn't work. INSERTing gives unique warning, and SELECT with accent results without accent (and vise versa).

Everywhere I looked says it should work. What am I missing then?

Update

Somehow I managed to make this, but work only with command prompt. Php still thinks SELECT "a" = "á" is TRUE.

user2563731
  • 71
  • 1
  • 7
  • Nope, the other question's answer didn't solve it either. Been on this problem for about 2 days now, with my classmate, and decided that I delete the UNIQUE attribute and try to limit input repeat with php... – user2563731 Nov 24 '13 at 08:57
  • `utf8_unicode_ci` is a very *permissive* collation in which "a" indeed equals "á". Use a `_bin` collation if you require _bin_ary equality. – deceze Nov 24 '13 at 09:25
  • Alright, so I've been misled somehow, I'll be using _bin. Thanks. _bin distinguises upper and lower case too, which I don't need. (I didnt mention this, because unicode doesn't do it.) But using LOWER(column) = LOWER(input) in my SELECT queries should solve this. – user2563731 Nov 24 '13 at 14:10
  • also, when using _bin and ordering by name, use "ORDER BY col_name COLLATE utf8_general_ci ASC" to handle accented letters and upper-lower case properly! – user2563731 Nov 25 '13 at 12:25

0 Answers0