Skip to content

Instantly share code, notes, and snippets.

@bagvendt
Created October 24, 2013 20:37
Show Gist options
  • Save bagvendt/7144563 to your computer and use it in GitHub Desktop.
Save bagvendt/7144563 to your computer and use it in GitHub Desktop.
Top 2 rated movies for actor_id = ?
SELECT actor_id, first_name, last_name, name FROM actors
JOIN `roles`
ON actors.`id` = roles.`actor_id`
JOIN `movies`
ON movies.`id` = `movie_id`
WHERE rank IS NOT NULL AND actor_id = %s
ORDER BY rank DESC
limit 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment