Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal mix of collations for operation 'like' while searching with Ignited-Datatables

I have successfully implemented Ignited-Datatables. However, while searching with database when typing "non-latin" characters like "İ,ş,ğ,.."

POST http://vproject.dev/module/user/ign_listing 500 (Internal Server Error)

Details are:

Illegal mix of collations for operation 'like' while searching
... (u.id_user LIKE '%Ä°%' OR u.first_name LIKE '%Ä°%' OR u.last_name LIKE '%Ä°%' OR ue.email LIKE '%Ä°%' OR u.last_login LIKE '%Ä°%' ) ...

%Ä°% part changes according to the non-latin character you typed.

Any idea for solving this?

like image 923
YahyaE Avatar asked Sep 05 '13 06:09

YahyaE


3 Answers

I figured out the problem. It seems it is DATETIME fields that causes the problem.

.. ue.last_login '%ayşenur%' 

gives error for Illegal mix of collations for operation 'like'. When I remove LIKE partials DATETIME fields, there are no error any more. I hope this helps.

like image 169
YahyaE Avatar answered Oct 12 '22 08:10

YahyaE


Try the following:

u.id_user LIKE '%Ä°%' OR ... OR ... '%Ä°%' COLLATE utf8_bin

Refer to MySQL Unicode Character Sets

Also you can refer to MySQL _bin and binary Collations for more information on utf8_bin:

Nonbinary strings (as stored in the CHAR, VARCHAR, and TEXT data types) have a character set and collation. A given character set can have several collations, each of which defines a particular sorting and comparison order for the characters in the set. One of these is the binary collation for the character set, indicated by a _bin suffix in the collation name. For example, latin1 and utf8 have binary collations named latin1_bin and utf8_bin.

like image 27
doitlikejustin Avatar answered Oct 12 '22 09:10

doitlikejustin


The question is a little bit old. Finally I find a solution change "LIKE " TO "LIKE binary "

like image 29
Tse Ka Leong Avatar answered Oct 12 '22 07:10

Tse Ka Leong