Skip to content

Instantly share code, notes, and snippets.

@matoakley
Created July 19, 2011 14:38
Show Gist options
  • Star 76 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save matoakley/1092571 to your computer and use it in GitHub Desktop.
Save matoakley/1092571 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`
@dominiquevienne
Copy link

Forgot to mention a useful thing:

If you search for rows with slugged issues, you can use

WHERE rowName <> CONVERT(rowName USING ASCII)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment