简体   繁体   中英

SQL query to create article alias from text

I have a CMS system that I have imported some articles into directly via the mySQL database. This works just fine. However, the article aliases were not created in the database, I would have to create those myself.

Can someone provide an example of a query that would take an article title string and convert it to a common alias format? I assume the query would look something like

UPDATE tblArticles SET ArticleAlias=XYZ(ArticleTitle)

It's the XYZ part above that I need help with to take an article title like "Is a kitchen remodel in your future?" to "kitchen-remodel-your-future'

You're probably looking for REPLACE

UPDATE tblArticles 
  SET ArticleAlias=REPLACE(ArticleTitle,' ','-');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM