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'
我的下面的查詢給了我錯誤後,我在哪裏做錯了請幫助我嗎?查詢不符合DATE_FORMAT
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
它並沒有DATE_FORMATE工作? –