SQL查询从文本创建文章别名

时间:2023-02-04 01:19:45

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.

我有一个CMS系统,我已经通过mySQL数据库直接导入了一些文章。这很好用。但是,文章别名不是在数据库中创建的,我必须自己创建。

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'

这是上面的XYZ部分,我需要帮助,以获取一篇文章标题,如“你的未来是一个厨房改造吗?”到“厨房 - 改造你的未来”

1 个解决方案

#1


3  

You're probably looking for REPLACE

你可能正在寻找REPLACE

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

#1


3  

You're probably looking for REPLACE

你可能正在寻找REPLACE

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