A comprehensive SQL function that converts strings into URL-friendly slugs by transliterating international characters and cleaning up formatting.
- International Character Support: Handles Cyrillic, Latin with diacritics, and Greek characters
- URL-Safe Output: Converts to lowercase and removes special characters
- Clean Formatting: Replaces spaces and dots with hyphens, removes multiple consecutive hyphens
- Deterministic: Same input always produces the same output
Execute the function definition in your MySQL database:
SELECT slugify('Hello World!');
-- Returns: 'hello-world'
SELECT slugify('Привет мир');
-- Returns: 'privet-mir'
SELECT slugify('Café & Restaurant');
-- Returns: 'cafe-restaurant'
SELECT slugify('múltiple---hyphens spaces');
-- Returns: 'multiple-hyphens-spaces'- Cyrillic: а→a, б→b, в→v, г→g, etc.
- Latin Diacritics: á→a, ñ→n, ç→c, etc.
- Greek: α→a, β→b, γ→g, etc.
- Special: ß→ss, æ→ae, œ→oe
- Lowercase alphanumeric characters and hyphens only
- No leading or trailing hyphens
- Single hyphens between words
- Maximum length: 255 characters
MIT License