MySQL Illegal mix of collations for operation 'like'

user-pic
Vote 0 Votes

在 MySQL 5.5 以上, 若欄位 Type 是 time,date,datetime
在 select 時若使用 like '%中文%' 會出現 Illegal mix of collations for operation 'like'
在寫程式時要對每個欄位進行搜尋, 在執行時可能就會出現時間欄位 like '%中文%' 這種語法,
這在舊版的 MySQL 是不會出現錯誤的.
升到 MySQL 5.5 以上, 必需改成 like binary '%中文%' 即可避免出現錯誤.

Leave a comment

About this Entry

This page contains a single entry by Pank published on April 12, 2013 10:22 AM.

Change sql_mode in MySQL 5.6 was the previous entry in this blog.

MSN相容性改Windows 2000 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives