Skip to content

Instantly share code, notes, and snippets.

@uu4hyu
Forked from matoakley/gist:1092571
Created March 14, 2019 08:01
Show Gist options
  • Select an option

  • Save uu4hyu/e2122a8861c08c44b8156e2a77f0b8e2 to your computer and use it in GitHub Desktop.

Select an option

Save uu4hyu/e2122a8861c08c44b8156e2a77f0b8e2 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