Mariadb除语句错误外

时间:2018-08-14 03:47:19

标签: mysql sql mariadb

关于此查询为何不适用于mariadb的任何想法?似乎遵循了mariadb文档网站上的模式

SELECT ...
(INTERSECT | EXCEPT | UNION [ALL | DISTINCT]) SELECT ...
( SELECT t1.visitid, t1. patientid, t1.visitdate
FROM db.medi_officevisit t1
WHERE t1.visitdate = (SELECT t2.visitdate
                 FROM db.medi_officevisit t2
                 WHERE t2.PatientID = t1.PatientID and VISITdate >= '2018-01-01'
                 ORDER BY t2.visitID DESC
                 LIMIT 1) )
EXCEPT
( SELECT t1.visitid, t1. patientid, t1.visitdate
FROM db.medi_officevisit t1
WHERE t1.visitdate = (SELECT t2.visitdate
                 FROM db.medi_officevisit t2
                 WHERE t2.PatientID = t1.PatientID and VISITdate >= '2017-01-01' and VISITDATE <= '2018-01-01'  
                 ORDER BY t2.visitID DESC
                 LIMIT 1) );
  

错误代码:1064。您的SQL语法有错误;检查   对应于您的MariaDB服务器版本的手册   在'EXCEPT(SELECT t1.visitid,t1。Patientid,   第8行的t1.visitdate FROM db.medi_o'

1 个答案:

答案 0 :(得分:0)

EXCEPT已在MariaDB 10.3.0版中添加。您需要升级您的MariaDB版本才能执行此操作。

如果不能,请参见Return row only if value doesn't exist

中的解决方案