简体   繁体   中英

illegal mix of collations in MySQL for operation =

I have a table abc that has 2 columns:

id INT(3) name VARCHAR(10)

The default collation for this table and for all of its column is utf8_unicode_ci

I then have another table xyz that has 2 columns:

id INT(3) name VARCHAR(10)

The default collation for this table and for all of its column is also utf8_unicode_ci

Now I am firing this select statement:

SELECT NAME FROM abc WHERE ID NOT IN (SELECT ID FROM XYZ);

I have checked the collations of both the tables and they are same, still, it gives me the error : illegal mix of collations (utf8_general_ci implicit) and (utf8_unicode_ci implicit) for operation =

I also tried an alternate for NOT IN ie by using LEFT JOIN but it still gives me the same error.

I have been stuck on this for a long time now. Any help is appreciated.Thanks

A likely workaround:

SELECT NAME
    FROM abc
    LEFT JOIN XYZ  USING(ID)
    WHERE XYZ.ID IS NULL;

Another help may be

SET NAMES utf8 COLLATE utf8_unicode_ci;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM