0

I get the following error:

Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'find_in_set'

This is the query I was trying to execute:

SELECT ID FROM xs_user_profiles WHERE ID='' AND FIND_IN_SET('1',site_structure);

I looked up the properties of this table and it has charset utf8 and collation utf8_general_ci.

This works well with all my sites so I am not sure what's going wrong.

bluish
  • 26,356
  • 27
  • 122
  • 180
sanders
  • 10,794
  • 27
  • 85
  • 127
  • Possible duplicate of [Troubleshooting "Illegal mix of collations" error in mysql](http://stackoverflow.com/questions/3029321/troubleshooting-illegal-mix-of-collations-error-in-mysql) – Jocelyn Jun 18 '16 at 07:12

2 Answers2

2

If you are using mysqli, issue this command right after connecting:

$mysqli->set_charset("utf8");

This will set your connection encoding to UTF8 (same as your table uses).

With plain mysql, use this:

mysql_query("SET NAMES utf8", $conn);
mysql_query("SET CHARACTER SET utf8", $conn);
Quassnoi
  • 413,100
  • 91
  • 616
  • 614
0

I'm guessing your string literal ('1') is in a different collation due to different connection variables. See here

Todd Gardner
  • 13,313
  • 39
  • 51