【发布时间】:2012-12-13 17:14:48
【问题描述】:
我会很清楚:在 MySQL 中创建视图没有该死的 Illegal mix of colations 错误的解决方案是什么。
我的SQL代码是这样的(有一些葡萄牙语单词),我的数据库默认排序规则是latin1_swedish_ci:
CREATE VIEW v_veiculos AS
SELECT
v.id,
v.marca_id,
v.modelo,
v.placa,
v.cor,
CASE v.combustivel
WHEN 'A' THEN 'Álcool'
WHEN 'O' THEN 'Óleo Diesel'
WHEN 'G' THEN 'Gasolina'
ELSE 'Não Informado'
END AS combustivel,
marcas.marca,
/*I think that the CONCAT and COALESCE below causes this error, when the next line the view works fine*/
CONCAT(marca, ' ', v.modelo, ' - Placa: ', v.placa, ' - Combustível: ', COALESCE(v.combustivel, 'Não informado')) AS info_completa
FROM veiculos v
LEFT JOIN
marcas on(marcas.id = v.marca_id);
我认为错误原因是因为我使用了 coalesce 和/或 concat,因为完整错误的描述告诉我:Illegal mix of collation ( latin1_swedish_ci,IMPLICIT) 和 (utf8_general_ci,COERCIBLE) 用于操作“coalesce”
【问题讨论】:
-
您可以在这个 stackoverflow 问题 [这里][1] [1] 中得到答案:stackoverflow.com/questions/3029321/…
-
@Chella 更改默认数据库整理不起作用。我已经试过了。
标签: mysql sql mysql-error-1064 collation