stark
stark

Reputation: 119

LIKE operator MySQL doesn't work

I tried to make search using LIKE operator:

SELECT author_id, header, text FROM blog_u.posts WHERE text LIKE '%Samsung%';

It works with latin symbols but doesn't work with russian

SELECT author_id, header, text FROM blog_u.posts WHERE text LIKE '%Проверка%';

My database in utf-8. Help me pls

Upvotes: 2

Views: 733

Answers (1)

sgeddes
sgeddes

Reputation: 62841

As a follow-up to my comment, I don't think you're having an issue with LIKE. However, you have to make sure what you're searching for have the equivalent ascii values.

For example, consider this:

select * from posts where Text Like '%Проверка%';
select ascii('p');
select ascii('р');

The 'p' looks identical in both, but the ascii version is indeed different -- one works, and the other doesn't. I copied the p in your above statement vs. just typing a p on my keyboard.

Here is a Fiddle to demonstrate.

Upvotes: 2

Related Questions