See the SQL query below, it count the total records that match with numbers and business tables.
SELECT N.mobile, B.name, count(*) as Total FROM records as R
LEFT JOIN business as B ON B.id = R.business_id
LEFT JOIN numbers as N ON N.id = R.numbers_id
group by N.mobile, B.name
However, there are remaining rows (N.mobile, B.name) that are not included in the result, how to include them and the Total would be 0?
Are you saying that there are
businessandnumbersrows that don’t have an entry inrecords, but you want to include them in the count? Since MySQL doesn’t support aFULL OUTER JOINuseUNIONto get the results you want: