作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
select d.doctorFName,d.doctorLName ,count(ap.appointmentID) totalap,
GROUP_CONCAT(DISTINCT s.speciality) specialities
FROM tbl_doctors d
INNER JOIN tbl_doctor_speciality ds ON (d.doctorID = ds.doctorID)
INNER JOIN tbl_speciality s ON (s.spID = ds.spID)
Inner join tbl_appointment ap on (ap.doctorID = d.doctorID)
Inner join tbl_patients p on p.patientID = ap.patientID
GROUP BY d.doctorID
where d.status = 1 and DATE_FORMAT(ap.appDate, '%Y-%m') = '2013-10'
我的下面的查询在我做错的地方后给了我错误,请帮助我?
where d.status = 1 and DATE_FORMAT(ap.appDate, '%Y-%m') = '2013-10'
错误
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where d.status = 1 and ds.spID and DATE_FORMAT(ap.appDate, '%Y-%m') = '2013-10' at line 9
最佳答案
where
子句位于错误的位置。它位于group by
之前:
select d.doctorFName,d.doctorLName ,count(ap.appointmentID) totalap,
GROUP_CONCAT(DISTINCT s.speciality) specialities
FROM tbl_doctors d
INNER JOIN tbl_doctor_speciality ds ON (d.doctorID = ds.doctorID)
INNER JOIN tbl_speciality s ON (s.spID = ds.spID)
Inner join tbl_appointment ap on (ap.doctorID = d.doctorID)
Inner join tbl_patients p on p.patientID = ap.patientID
where d.status = 1 and DATE_FORMAT(ap.appDate, '%Y-%m') = '2013-10'
GROUP BY d.doctorID;
关于mysql - 查询不适用于 DATE_FORMAT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22117319/
我是一名优秀的程序员,十分优秀!