Illegal mix of collations error in MySql

后端 未结 19 2235
醉梦人生
醉梦人生 2020-11-29 01:11

Just got this answer from a previous question and it works a treat!

SELECT username, (SUM(rating)/COUNT(*)) as TheAverage, Count(*) as TheCount 
FROM ratings         


        
19条回答
  •  温柔的废话
    2020-11-29 01:56

    I think you should convert to utf8

    --set utf8 for connection
    SET collation_connection = 'utf8_general_ci'
    --change CHARACTER SET of DB to utf8
    ALTER DATABASE dbName CHARACTER SET utf8 COLLATE utf8_general_ci
    --change CHARACTER SET of table to utf8
    ALTER TABLE tableName CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci
    

提交回复
热议问题