Skip to content

Instantly share code, notes, and snippets.

@Yiling-J
Last active February 28, 2020 04:03
Show Gist options
  • Save Yiling-J/278fd559362d65f2df4742dd4b180034 to your computer and use it in GitHub Desktop.
Save Yiling-J/278fd559362d65f2df4742dd4b180034 to your computer and use it in GitHub Desktop.
mysql comma-separated string remove duplicate(using mysql 5.7)
-- this will return no duplicate json array, then you can use replace to get normal string
SELECT JSON_KEYS(JSON_MERGE(concat('{"', Replace('martini,martini,coffee,espresso', ',', '":1,"'), '":1}'), concat('{"', Replace('martini,martini,coffee,espresso', ',', '":1,"'), '":1}')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment