Skip to content

Instantly share code, notes, and snippets.

@mrbrdo
Last active December 25, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbrdo/6987647 to your computer and use it in GitHub Desktop.
Save mrbrdo/6987647 to your computer and use it in GitHub Desktop.
# AR and Sequel - results in single query, *not* two
Artist.where(id: Album.select(:artist_id))
# SELECT artists.* FROM artits WHERE id IN (SELECT artist_id FROM albums)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment