Home > Article > Backend Development > zen cart order search function, use Chinese keyword search, Illegal mix of collations for o_PHP tutorial appears
zen cart version is 1.3.9
Enter the zen cart backend, customer management -> order management, use the order search function, the keyword is Chinese: Li Chao, the following error occurs during the search:
1271 Illegal mix of collations for operation 'like'
in:
[select count(*) as total from (zc_orders_status s, zc_orders o ) left join zc_orders_total ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') where (o.orders_status = s.orders_status_id and s.language_id = '2') and (o.customers_city like '% Li Chao%' or o.customers_postcode like '%Li Chao%' or o.date_purchased like '%Li Chao%' or o.billing_name like '%Li Chao%' or o.billing_company like '%Li Chao%' or o .billing_street_address like '%李超%' or o.delivery_city like '%李超%' or o.delivery_postcode like '%李超%' or o.delivery_name like '%李超%' or o.delivery_company like '%李Chao%' or o.delivery_street_address like '%李超%' or o.billing_city like '%李超%' or o.billing_postcode like '%李超%' or o.customers_email_address like '%李超%' or o. customers_name like '%李超%' or o.customers_company like '%李超%' or o.customers_street_address like '%李超%' or o.customers_telephone like '%李超%' or o.ip_address like '%李超%' %')]
Analyzing this problem from the perspective of SQL statements, it was found that o.date_purchased like '%李超%' caused the entire SQL statement to report an error
In MySQL 5.5 or above, if the field Type is time, date, datetime
If you use like '%中文%' when selecting, Illegal mix of collations for operation 'like' will appear
When writing a program, you need to search for each field. When executing, a time field like '%中文%' may appear,
This error will not occur in older versions of MySQL. But when upgrading to MySQL 5.5 or above, you must change it to like binary '%中文%' to avoid errors