Mysql multi-table query 1267 error report

const books = await mysql("books")
                  .select("books.*","csessioninfo.user_info")
                  .join("csessioninfo","books.openid","csessioninfo.open_id")
                  // .orderBy("id","desc")
 code: "ER_CANT_AGGREGATE_2COLLATIONS", errno: 1267, sqlMessage: "Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operation \"=\"", sqlState: "HY000", index: 0, sql: "select `books`.*, `csessioninfo`.`user_info` from `books` inner join `csessioninfo` on `books`.`openid` = `csessioninfo`.`open_id`" } +1ms

execute the above code with an error of 1267. I don"t know what caused it.


mysql> select `books`.*, `csessioninfo`.`user_info` from `books` inner join `csessioninfo` on `books`.`openid` = `csessioninfo`.`open_id`
    -> ;
ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operation "="
Mar.19,2021

you can see from the error message that the sorting rules of the books table and csessioninfo are inconsistent. You can modify the books table to change the collation to utf8mb4_unicode_ci .

Menu