Created
April 22, 2011 20:44
-
-
Save oleander/937577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT COUNT(*) AS count_all, movies.id AS movies_id FROM `movies` | |
INNER JOIN `genres_movies` ON `genres_movies`.`movie_id` = `movies`.`id` | |
INNER JOIN `genres` ON `genres`.`id` = `genres_movies`.`genre_id` | |
INNER JOIN `torrents` ON `torrents`.`movie_id` = `movies`.`id` | |
INNER JOIN `trackers` ON `trackers`.`id` = `torrents`.`tracker_id` | |
LEFT JOIN formats_torrents ON formats_torrents.torrent_id = torrents.id | |
LEFT JOIN formats ON formats.id = formats_torrents.format_id | |
LEFT JOIN images ON images.movie_id = movies.id | |
LEFT JOIN sizes ON sizes.id = images.size_id | |
WHERE `genres`.`id` IN (2, 3) AND | |
`trackers`.`id` IN (2, 3, 1) AND | |
`movies`.`active` = 1 AND | |
(`movies`.`rating` BETWEEN 4 AND 10) AND | |
(torrents.subtitles_count >= 1) AND | |
(formats.id IN ('1','2') OR | |
formats.id IS NULL) AND | |
(torrents.source_id IN ('1','2') OR | |
torrents.source_id IS NULL) AND | |
((MATCH (torrents.title) AGAINST('The' IN BOOLEAN MODE) OR | |
MATCH(movies.title) AGAINST('The' IN BOOLEAN MODE))) AND | |
(sizes.name = 'cover' OR | |
images.id IS NULL) | |
GROUP BY movies.id | |
ORDER BY movies.title desc | |
LIMIT 52 OFFSET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment