Skip to content

Instantly share code, notes, and snippets.

@wouldhide
Created July 1, 2016 12:03
Show Gist options
  • Save wouldhide/2f37bf78f3db3821c2114df6009ea45c to your computer and use it in GitHub Desktop.
Save wouldhide/2f37bf78f3db3821c2114df6009ea45c to your computer and use it in GitHub Desktop.
# feel free to add new rows for other special characters
UPDATE table_to_update SET `slug` = lower(field_to_slugify),
slug = replace(slug, '.', ' '),
slug = replace(slug, ',', ''),
slug = replace(slug, '\'', '-'),
slug = replace(slug, '/', '-'),
slug = replace(slug,'á','a'),
slug = replace(slug,'é','e'),
slug = replace(slug,'í','i'),
slug = replace(slug,'ó','o'),
slug = replace(slug,'ö','o'),
slug = replace(slug,'ő','o'),
slug = replace(slug,'ú','u'),
slug = replace(slug,'ü','u'),
slug = replace(slug,'ű','u'),
slug = trim(slug),
slug = replace(slug, ' ', '-'),
slug = replace(slug, '--', '-'),
slug = replace(slug, '---', '-')
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment