MySQL Illegal mix of collations for operation 'like'

来源:互联网 发布:渗透理论 复杂网络 编辑:程序博客网 时间:2024/05/18 07:24
在 MySQL 5.5 以上, 若欄位 Type 是 time,date,datetime 
在 select 時若使用 like '%中文%' 會出現 Illegal mix of collations for operation 'like'
在寫程式時要對每個欄位進行搜尋, 在執行時可能就會出現時間欄位 like '%中文%' 這種語法,
這在舊版的 MySQL 是不會出現錯誤的.

升到 MySQL 5.5 以上, 必需改成 like binary '%中文%' 即可避免出現錯誤.


在使用mysql执行update的时候,如果不是用主键当where语句,会报如下错误,使用主键用于where语句中正常。

异常内容:Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect.


这是因为MySql运行在safe-updates模式下,该模式会导致非主键条件下无法执行update或者delete命令,执行命令SET SQL_SAFE_UPDATES = 0;修改下数据库模式

SET SQL_SAFE_UPDATES = 0;


order by field(value,str1,str2,str3,str4,,,,,,strn);

ORDER BY  field(B.CentaAreaName,'华南区','华东区','华北区','华西区','东北区','集团','')

0 0