Skip to content

Instantly share code, notes, and snippets.

@ognjenm
Created September 25, 2016 08:28
Show Gist options
  • Select an option

  • Save ognjenm/7d59b6c82ee1d0e3376e717b957a6363 to your computer and use it in GitHub Desktop.

Select an option

Save ognjenm/7d59b6c82ee1d0e3376e717b957a6363 to your computer and use it in GitHub Desktop.
MySQL create slug from title
UPDATE some_table SET slug = LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM(title_field),'ž',''),'đ',''),'š',''),'ć',''),'č',''), ':', ''), ')', ''), '(', ''), ',', ''), '\\', ''), '\/', ''), '\"', ''), '?', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '--', '-'), '--', '-'))
WHERE slug = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment