1
votes

I am trying this:

SET @query1 =  'star';
   SELECT *
   FROM businesses
   WHERE business_name LIKE @query1

But i get following error:

Error Code: 1267 Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'like'

What am I doing wrong?

2
can you please tell your mysql version. - S. M. Mohiuddin
I have just checked in phpmyadmin and it is working. - Amit Garg
@S.M.Mohiuddin - Server version: 5.5.40-cll - NoviceMe
@AmitGarg - i am trying to use this in phpMyAdmin. It is not working - NoviceMe

2 Answers

3
votes

Just specify the collation

SELECT * FROM businesses WHERE business_name LIKE @query1 COLLATE utf8_unicode_ci

For a more permanent fix you need to change the collation of the server to be compatible with the db or viceversa.I dont have much experience in collations so you have do to a bit of reading.

Docs

0
votes

weird.. but you can convert your table to that charset like:

ALTER TABLE mydb.businesses  DEFAULT COLLATE utf8_unicode_ci;
ALTER TABLE mydb.businesses CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;