Bạn đang sử dụng LEFT JOIN , nhưng trong câu lệnh where của bạn khiến nó trở thành JOIN 'bình thường'
Hãy thử viết nó như thế này:
SELECT months_tbl.month, COUNT( events_tbl.appt_id ) cnt
FROM months_tbl
LEFT JOIN events_tbl ON (months_tbl.month_id = MONTH(events_tbl.appt_date_time)
AND events_tbl.company_id = 1
)
GROUP BY months_tbl.month
ORDER BY months_tbl.month_id ASC;
Lưu ý AND events_tbl.company_id = 1 nằm trong LEFT JOIN