asdfgsdfv
asdfgsdfv

Reputation: 167

MySQL comparing UTF-8 strings

I have created a table AddictionText.

CREATE TABLE `AddictionText` (
`Condition` VARCHAR(255) NOT NULL);

It's filled with UTF-8 characters, such as

INSERT INTO AddictionText VALUES ('šarec')

When I compare it with the word sarec I still get a single hit. I was expecting no results.

select * from AddictionText where AddictionText.Condition='sarec'  --mind you, first character is S not Š

Can someone please help me out, what am I doing wrong?

Upvotes: 1

Views: 627

Answers (1)

Evert
Evert

Reputation: 99505

What is 'equal' in strings depends on language and culture, and this is true for MySQL as well.

I don't know what language šarec is, but to me searching for 'Sarec' and getting a result makes sense.

If that's not the case for you, you want to look for a 'collation' that better matches your expectations.

MySQL documentation has more information:

Upvotes: 2

Related Questions