I have a table with titles in Cyrillic alphabet. LIKE
seems to ignore certain words in Russian. Collation UTF8_general_ci
. I tried execute request from php as well as from PHPMyAdmin. What can be possible reason?
SELECT * FROM `table` WHERE `column` LIKE 'слово'
UPD: Here is example: http://sqlfiddle.com/#!9/30d904/1/0
3
Answers
try like this :
just add
%
at the beginning and the end of your search string (word).for example. change
'все'
to'% все %'
.Your Example
But if you want it to be not case sensitive then
Not case sensitive Example
When you use
the query matches titles that are equal to
'все'
becauseLIKE
without wildcards is equivalent to=
(with the possible exception of case sensitivity).But you want titles that contain the word
'все'
, meaning titles that would be anywhere inside the column value preceded and followed by a space (except when it is at the start or at the end).So use the operator
LIKE
like this:See the demo.
Results:
http://sqlfiddle.com/#!9/62292ea/1
The regular expression pattern works with word boundaries (space, comma, etc.) as well as with begin|end of string. I applied lower() function for case insensitivity.
So it matches “Все в гости к нам” and doesn’t match “Повсеместно”