Created
November 24, 2014 00:41
-
-
Save jeremywrowe/954d8a93b06b4894c580 to your computer and use it in GitHub Desktop.
MySql Group Concat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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