Double JOINTURE GAUCHE

Je veux recevoir nom de la propriété et des unités de comptage et specails comte. J'ai cette requête:

SELECT 
  `property`.`property_name`,
  COUNT(unit_id) AS `units_count`,
  COUNT(special_id) AS `specials_count` 
FROM `property`
  LEFT JOIN `property_unit` ON unit_property_id = property_id
  LEFT JOIN `property_special` ON special_property_id = property_id
WHERE (property_id = '1')
GROUP BY `property_id`
ORDER BY `property_name` ASC

Mais il ne fonctionne pas correctement. Si j'en ai un de ces left join - c'est ok, mais si j'en ai deux, j'obtiens ce résultat:

["property_name"] => string(11) "Rivers Edge"
["units_count"] => string(1) "2"
["specials_count"] => string(1) "2"

Specials nombre est 2 et units_count est de 2, mais les unités de comptage est vraiment '1'. Comment puis-je obtenir bon compte pour?

P. S: pour ceux qui connaissent le Zend Framework:

$select->setIntegrityCheck(FALSE)
    ->from(
        'property',
        array(
            'property_name',
        )
    )
    ->joinLeft(
        'property_unit',
        'unit_property_id = property_id',
        array(
            'units_count' => 'COUNT(unit_id)'
        )
    )
    ->joinLeft(
        'property_special',
        'special_property_id = property_id',
        array(
            'specials_count' => 'COUNT(special_id)'
        )
    )
    ->group('property_id')
    ->order('property_name');
Sont unit_id et special_id clés uniques sur les property_unit et property_special tables?
Bannister Oui

OriginalL'auteur Dmitry Teplyakov | 2011-12-07