Skip to content

Instantly share code, notes, and snippets.

@cengizhancaliskan
Created November 25, 2017 19:58
Show Gist options
  • Save cengizhancaliskan/3a4d148ab244bfb7dfeb367fc798f893 to your computer and use it in GitHub Desktop.
Save cengizhancaliskan/3a4d148ab244bfb7dfeb367fc798f893 to your computer and use it in GitHub Desktop.
Generate slug in mysql
# generate slug
UPDATE table_name SET slug = replace(trim(lower(name)), ' ', '-');
# check irregular slug..
SELECT * FROM table_name WHERE slug NOT RLIKE '^([a-z0-9]+\-)*[a-z0-9]+$';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment