我不知道这里有什么问题。我正在使用3个表的多个连接运行查询,下面的查询完美地工作... 给我员工的详细信息,他的年龄,如果他需要证书并给我关于证书到期日的信息,也会给我一个" - "在下一个领域,如果不需要证书 - 正如我所说,这就像一个魅力......
SELECT
`employee`.*,
date_format(now(), '%Y') - date_format(`empl_dob`, '%Y') -
(date_format(now(), '00-%m-%d') < date_format(`empl_dob`, '00-%m-%d')) AS age,
`certs`.`cert_medical_restrict`,
IF( `jobtitle`.`jt_medical`='n/a', `jobtitle`.`jt_medical`,
IF( `certs`.`cert_medical` = 0, 'No Cert',
IF( (DATEDIFF((DATE_ADD(`certs`.`cert_medical`, INTERVAL 365 DAY)),CURDATE())) < 1, 'X',
IF( (DATEDIFF((DATE_ADD(`certs`.`cert_medical`, INTERVAL 365 DAY)),CURDATE())) < 30, 'ES', 'ok')))
) AS medical,
IF( `jobtitle`.`jt_medical`='n/a', '-',
IF( `certs`.`cert_medical` = 0, '-', (DATEDIFF((DATE_ADD(`certs`.`cert_medical`, INTERVAL 365 DAY)),CURDATE())))) AS medicalx
FROM `employee`
JOIN `jobtitle`
ON `employee`.`jobtitle_id` = `jobtitle`.`jobtitle_id`
JOIN `certs`
ON `certs`.`empl_idno` = `employee`.`empl_idno`
WHERE `employee`.`empl_no` = '10517602'
...但是对于我的下一个查询,我需要显示证书的实际到期日期,查询看起来非常相似,但没有额外的IF语句......
SELECT
`employee`.*,
date_format(now(), '%Y') - date_format(`empl_dob`, '%Y') -
(date_format(now(), '00-%m-%d') < date_format(`empl_dob`, '00-%m-%d')) AS age,
`certs`.`cert_medical_restrict`,
IF( `jobtitle`.`jt_medical`='n/a', `jobtitle`.`jt_medical`,
IF( `certs`.`cert_medical` = 0, 'No Cert', (DATE_ADD(`certs`.`cert_medical`, INTERVAL 365 DAY)))) AS medical,
IF( `jobtitle`.`jt_medical`='n/a', '-',
IF( `certs`.`cert_medical` = 0, '-', (DATEDIFF((DATE_ADD(`certs`.`cert_medical`, INTERVAL 365 DAY)),CURDATE())))) AS medicalx
FROM `employee`
JOIN `jobtitle`
ON `employee`.`jobtitle_id` = `jobtitle`.`jobtitle_id`
JOIN `certs`
ON `certs`.`empl_idno` = `employee`.`empl_idno`
WHERE `employee`.`empl_no` = '10517602'
现在我收到此错误&#34;非法混合排序(latin1_swedish_ci,IMPLICIT)和(utf8mb4_general_ci,COERCIBLE)进行操作&#39;如果&#39; &#34; 我无法理解它,我已经检查了三个表是否彼此不同,但都设置为&#34; latin_swedish_ci&#34;
我在这里做错了什么?任何帮助将不胜感激 - thanx