error Illegal mix of collations for concat

时光总嘲笑我的痴心妄想 提交于 2019-12-04 06:22:08

问题


Iam trying to execute database

SELECT v.id AS id,
       DATE_FORMAT(v.`date`, '%d %b %y') AS `date`,
       `getDateDiff`(v.`date`) AS `datediff`,
       c.`name` AS `clinic`,
       GROUP_CONCAT(CONCAT(an.anamnese, ', ', an.icd_name, '') SEPARATOR '|') AS anamnese_diagnose,
       GROUP_CONCAT(tr.name SEPARATOR '|') AS treatment,
       GROUP_CONCAT(CONCAT(pr.drug_name, '  (', format(pr.dosis1,0), ' x ', format(pr.dosis2,0), ')',' Jml: ',substring_index(pr.qty,'.',1),' ',pr.unit) SEPARATOR '|') AS prescribe,
       CONCAT_WS('/', ex.sistole, ex.diastole) AS blood_pressure,
       ex.temperature AS temperature,
       ex.pulse AS pulse,
       ex.physic_anamnese AS physic_anamnese,
       ex.respiration AS respiration,
       ex.weight AS weight,
       ex.height AS height
FROM `examinations` ex
JOIN `visits` v ON (v.id = ex.visit_id)
JOIN `ref_clinics` c ON (c.id = v.clinic_id)
JOIN `patients` p ON (p.id = v.patient_id)
LEFT JOIN anamnese_diagnoses an ON (an.visit_id = v.id)
LEFT JOIN treatments tr ON (tr.visit_id = v.id)
LEFT JOIN prescribes pr ON (pr.visit_id = v.id)
WHERE v.id <= '19499'
  AND v.patient_id=
    (SELECT patient_id
     FROM visits
     WHERE id='19499')
GROUP BY v.id
ORDER BY v.id DESC LIMIT 1

But system said A Database Error Occurred

Error Number: 1271

Illegal mix of collations for operation 'concat' can anyone help me ?


回答1:


I had a similar issue lately. Before you concat do a

... CONVERT(myCol TO utf8)...

for all your cols that you want to concat.



来源:https://stackoverflow.com/questions/27226089/error-illegal-mix-of-collations-for-concat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!