Skip to content

Instantly share code, notes, and snippets.

@incorvia
Created October 9, 2011 23:45
Show Gist options
  • Save incorvia/1274376 to your computer and use it in GitHub Desktop.
Save incorvia/1274376 to your computer and use it in GitHub Desktop.
Command:
User.joins(:tags).select("users.email, tags.tag_name")
SQL:
SELECT users.email, tags.tag_name FROM `users` INNER JOIN `notecards` ON `notecards`.`user_id` = `users`.`id` INNER JOIN `associations` ON `associations`.`notecard_id` = `notecards`.`id` INNER JOIN `tags` ON `tags`.`id` = `associations`.`tag_id`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment