Задавайте вопросы, мы ответим
Вы не зашли.
хочу сделать запрос из 8 таблиц, не получается
$num = 6; $page = $_GET['page']; $result = mysql_query("(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; $total = intval(($posts - 1) / $num) + 1; $page = intval($page); if(empty($page) or $page < 0) $page = 1; if($page > $total) $page = $total; $start = $page * $num - $num; $sql = "(SELECT photo.id_factory, photo.id AS id_photo, photo.url AS url_photo, factory.id AS id_factory, factory.name AS name_factory, factory.url AS url_factory 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 other_photo.id_factory, other_photo.id AS id_photo, other_photo.url AS url_photo, factory.id AS id_factory, factory.name AS name_factory, factory.url AS url_factory 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 ) LIMIT $start, $num "; $photo = mysql_query($sql);
выдает неправильное количество строк
где я ошибся в первом запросе?
Отредактированно sc2r2bey (07.05.2010 13:24:29)
Неактивен
А почему Вы думаете, что неправильное? )
И нужны ли Вам LEFT JOIN?
Неактивен