简体   繁体   English

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

[英]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.我有一个 CMS 系统,我直接通过 mySQL 数据库将一些文章导入其中。 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?"这是上面的XYZ部分,我需要帮助才能获得像“你未来会改造厨房吗?”这样的文章标题。 to "kitchen-remodel-your-future'到“厨房改造你的未来”

You're probably looking for REPLACE您可能正在寻找REPLACE

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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