Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Created November 24, 2014 00:41
Show Gist options
  • Save jeremywrowe/954d8a93b06b4894c580 to your computer and use it in GitHub Desktop.
Save jeremywrowe/954d8a93b06b4894c580 to your computer and use it in GitHub Desktop.
MySql Group Concat
Customer.joins(subscriptions: :product).group(:email).select('GROUP_CONCAT(DISTINCT subscriptions.state SEPARATOR ":::") AS states, GROUP_CONCAT(DISTINCT products.name SEPARATOR ":::") AS product_names, first_name, last_name').last.states
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment