MySQL - Counting rows and left join problem
问题 I have 2 tables, campaigns and campaign_codes: campaigns: id, partner_id, status campaign_codes: id, code, status I want to get a count of all campaign_codes for all campaigns WHERE campaign_codes.status equals 0 OR where there are no campaign_codes records for a campaign. I have the following SQL, but of course the WHERE statement eliminates those campaigns which have no corresponding records in campaign_codes ( i want those campaigns with zero campaign_codes as well) SELECT c.id AS campaign