Special character request

I have a problem with special characters in my database. Now they are displayed correctly, but sql seems to ignore them in the queries. For example, unfortunately, I have the following entries:

Morgait
Morgaít
Mórgait

Now these names had a UNIQUE key, and, trying to add the second and third after the first, he would already break the word that the last 2 could not be added, since the name would no longer be unique. In short, í is regarded as normal i, and - as normal o.

When I request: SELECT * FROM member WHERE charname = 'Morgait' I get all 3 as a result. The same thing when I change I to í, o to - or even to both at the same time.

How can I make the database see these differences? I have a mapping of the table set in ascii_general_ci (UIF 8 unicode ci was also used).

+3
source share
1 answer

All these comparisons accent insensitive. You can try utf8_binthat accent sensitive, but also case sensitive. In case of accent insensitive collaborations, for example, éequal to eor ëetc.

SELECT * FROM member WHERE charname = 'Morgait' COLLATE utf8_bin 

gotta do the trick. If you need case insensitivity, you can try

SELECT * FROM member WHERE LOWER(charname) = LOWER('Morgait') COLLATE utf8_bin
+1
source

All Articles