Answer the question
In order to leave comments, you need to log in
How to combine 2 queries with different where?
There are 2 requests:
SELECT COUNT(schedule.id) AS Total, doctor_id, doctor.last_name FROM `schedule`
INNER JOIN doctor ON `schedule`.doctor_id = doctor.id
WHERE `date` BETWEEN '2017-06-06' AND '2017-08-06'
GROUP BY doctor_id
SELECT COUNT(schedule.id) AS Worked, doctor_id, doctor.last_name FROM `schedule`
INNER JOIN doctor ON `schedule`.doctor_id = doctor.id
WHERE `date` BETWEEN '2017-06-06' AND '2017-08-06' AND schedule.appointment_cnt > 0
GROUP BY doctor_id
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question