Skip to content

Instantly share code, notes, and snippets.

@vambroise
Forked from matoakley/gist:1092571
Created August 23, 2018 07:23
Show Gist options
  • Save vambroise/32a3bc53d66b6095e6dc6e9d66f9196c to your computer and use it in GitHub Desktop.
Save vambroise/32a3bc53d66b6095e6dc6e9d66f9196c to your computer and use it in GitHub Desktop.
MySQL to convert a string into a slug
LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM('My String'), ':', ''), ')', ''), '(', ''), ',', ''), '\\', ''), '\/', ''), '\"', ''), '?', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '--', '-'), '--', '-')) AS `post_name`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment