0

I want to convert all my title names to a url alias using SQL query . currently im using sql REPLACE for replace "" (space) with "-" .

But i want to avoid all speacial charactors and spaces between words and convert the title names to aliases

Ex: A B & sons should be a-b-sons

This is my current query

 UPDATE content SET alias = title,alias = LOWER(REPLACE(alias," ", "-"));​

is there any option where i can add more speicifed for abocve query for get titles like above with special characters

Ex: A B & sons should be a-b-sons

Please advice

Mureinik
  • 297,002
  • 52
  • 306
  • 350
user3786234
  • 115
  • 1
  • 1
  • 12

1 Answers1

0

You can use REPLACE() function multiple time like

UPDATE content 
SET alias = LOWER(REPLACE(REPLACE(alias," ", "-"),"&","-"))
WHERE alias='A B & sons';
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • will it give outcome with multiple hiphens (-) between words. is it possible to remove "&" using replace wthout adding "-". Pls advice – user3786234 Jul 23 '14 at 18:58
  • Per your post: if alias value is `A B & sons` then the query will result in `a-b-sons`. Try it and see for yourself. Yes, you can replace without adding "-" but you will have provide a replacing character. – Rahul Jul 23 '14 at 19:04
  • @user3786234, consider accepting the answer if it helped by clicking the check button under voting button. – Rahul Jul 24 '14 at 19:48