Skip to content

Instantly share code, notes, and snippets.

@oleander
Created June 4, 2011 11:48
Show Gist options
  • Select an option

  • Save oleander/1007835 to your computer and use it in GitHub Desktop.

Select an option

Save oleander/1007835 to your computer and use it in GitHub Desktop.
SELECT movies.title, movies.rating, images.url as poster
FROM movies
INNER JOIN torrents ON torrents.movie_id = movies.id
INNER JOIN trackers ON trackers.id = torrents.tracker_id
LEFT JOIN images ON images.movie_id = movies.id
LEFT JOIN sizes ON sizes.id = images.size_id
WHERE movies.active = 1 AND
trackers.id IN (2, 3, 4, 1) AND
(sizes.name = 'cover' OR images.id IS NULL)
GROUP BY movies.id
ORDER BY movies.rating ASC
LIMIT 52 OFFSET 468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment