Skip to content

Instantly share code, notes, and snippets.

@miznokruge
Forked from matoakley/gist:1092571
Created January 14, 2021 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miznokruge/3b4c1839108db439a3c18699d934e492 to your computer and use it in GitHub Desktop.
Save miznokruge/3b4c1839108db439a3c18699d934e492 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