Illegal mix of collations error in MySql

后端 未结 19 2216
醉梦人生
醉梦人生 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 02:16

    I also got same error, but in my case main problem was in where condition the parameter that i'm checking was having some unknown hidden character (+%A0)

    When A0 convert I got 160 but 160 was out of the range of the character that db knows, that's why database cannot recognize it as character other thing is my table column is varchar

    • the solution that I did was I checked there is some characters like that and remove those before run the sql command

    • ex:- preg_replace('/\D/', '', $myParameter);

提交回复
热议问题