Advertisement
cahyadsn

Slugify Query from Field Value

Nov 15th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.63 KB | None | 0 0
  1. -- table_name : the name of table that you want to update
  2. -- field_slug_name : the name of field/column on the `table_name` above to store slugify value (destination field)
  3. -- field_title_name : the name of field/column on the `table_name` above that would be slugify (source field)
  4. --
  5. UPDATE table_name
  6. SET
  7. field_slug_name=
  8. LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM(field_title_name), ':', ''), ')', ''), '(', ''), ',', ''), '\\', ''), '\/', ''), '\"', ''), '?', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '--', '-'), '--', '-'));
  9. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement