Skip to content

Instantly share code, notes, and snippets.

@igaln
Created August 27, 2013 20:25
Show Gist options
  • Save igaln/6358682 to your computer and use it in GitHub Desktop.
Save igaln/6358682 to your computer and use it in GitHub Desktop.
Take a column value of comma delimited strings, compare it to another table ids to retrieve values belonging to each delimeted value, group them back into a comma delimited string, and store them in a column using GROUP_CONCAT
SELECT v2m6q_npg_plants.name, GROUP_CONCAT(v2m6q_npg_plants_seasons.name) as seasons FROM v2m6q_npg_plants, v2m6q_npg_plants_seasons WHERE find_in_set(v2m6q_npg_plants_seasons.id, v2m6q_npg_plants.seasons)>0
GROUP BY name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment