(SELECT COUNT(*)
FROM `photo`
LEFT JOIN `factory`
ON photo.id_factory=factory.id
LEFT JOIN `type`
ON photo.id_type=type.id
LEFT JOIN `style`
ON photo.id_style=style.id
WHERE photo.id_factory='$factory'
AND photo.published=1
AND type.published=1
AND style.published=1
AND factory.published=1)
UNION ALL
(SELECT COUNT(*)
FROM `other_photo`
LEFT JOIN `factory`
ON other_photo.id_factory=factory.id
LEFT JOIN `other`
ON other_photo.id_other=other.id
WHERE other_photo.id_factory='$factory'
AND other_photo.published=1
AND factory.published=1
AND other.published=1)
");
$posts = mysql_result($result,0);
echo $posts;
считает не правильно
выдает значение только 1-й таблицы, а надо, чтоб сумма была