Ver originalSELECT t2.clave2, IFNULL(COUNT(t2.clave2),0) total FROM tabla2 t2 LEFT JOIN tabla1_tiene_tabla2 t1t2 ON t2.clave2 = t1t2.clave2 GROUP BY t2.clave2