18.02.2011, 15:18
Наслаждайся
это 1 запрос

Code:
SELECT u.`id` object_id, 3 object_type, 3 object_weight, CONCAT ( '/movies/archive/', u.`id` ) `link`, CONCAT( IF ( ( (u.`original_name` IS NOT NULL) && (u.`original_name` != '') ), CONCAT ( u.`name`, ' – ', u.`original_name` ), u.`name` ), ' (', IF ( (u.`produced_end` > 0), CONCAT ( u.`produced_start`, ' – ', u.`produced_end` ), u.`produced_start` ), ')' ) AS `title`, CONCAT( GROUP_CONCAT( t.`name` SEPARATOR ', ' ), ', ', GROUP_CONCAT( p.`local_name` SEPARATOR ', ' ), ', ', GROUP_CONCAT( p.`original_name` SEPARATOR ', ' ) ) `tags`, CONCAT ( u.`announce`, ' ', u.`description` ) `text`, UNIX_TIMESTAMP( u.`updated` ) `pub`, rr.`sum` `rate` FROM `video_units` AS u LEFT JOIN `tags2objects` AS t2o ON t2o.`object_id` = u.`id` AND t2o.`object_type_id` = 3 AND t2o.`tag_group_id` IN (2, 8, 6) LEFT JOIN `tags` AS t ON t.`tag_id` = t2o.`tag_id` LEFT JOIN `object2object` AS o2o ON o2o.`related_object_id` = u.`id` AND o2o.`relation_type_id` IN (47, 54, 55, 56, 57, 58) LEFT JOIN `persons` AS p ON p.`id` = o2o.`object_id` LEFT JOIN `rating_result` AS rr ON rr.`object_type` = 3 AND rr.`object_id` = u.`id` # WHERE (DATE_ADD(u.`updated`, INTERVAL 30 MINUTE) > NOW()) GROUP BY u.`id`
