Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheHiddenHaku/70a0c94585956442ecdc141cf1cd3667 to your computer and use it in GitHub Desktop.
Save TheHiddenHaku/70a0c94585956442ecdc141cf1cd3667 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