Skip to content

Instantly share code, notes, and snippets.

@locvfx
Forked from matoakley/gist:1092571
Created November 7, 2016 03:14
Show Gist options
  • Save locvfx/57e0633138d3abf09c9c59a1cd32f333 to your computer and use it in GitHub Desktop.
Save locvfx/57e0633138d3abf09c9c59a1cd32f333 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