你知道为什么这个查询对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,t1.8号线医务室探视日期
1条答案
按热度按时间cpjpxq1n1#
EXCEPT
在mariadb版本10.3.0中添加。你需要升级你的mariadb版本才能做到这一点。如果不能,则仅当值不存在时才在返回行中查看解决方案