网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   MySQL (https://www.0058.net/forumdisplay.php?f=76)
-   -   批量去除MySQL数据库中文章内容的超链接 (https://www.0058.net/showthread.php?t=4382)

topvip 2012-07-10 05:11 AM

批量去除MySQL数据库中文章内容的超链接
 
此方法是在保留文章内容的情况下去除超链接,适用于信息采集时入库有别人的链接,自己写着玩的,高手莫见笑 先删除文章内容中超链接的前半部分: update articleset article_info.conten
此方法是在保留文章内容的情况下去除超链接,适用于信息采集时入库有别人的链接,自己写着玩的,高手莫见笑

先删除文章内容中超链接的前半部分:

update articleset article_info.content =
replace(article.content,
substring(article.content,
locate('<a ', article.content),
locate('>', article.content,locate('<a ', article.content))+1-locate('<a ', article.content)
),
'');

上部代码执行一次能够删除文章内容中的第一个超链接,多执行几次指导影响行数为0为止



下面就是删除文章内容中超链接的后半部分:

update article_info set article_info.content =
replace(article_info.content,'</a>','');

另一个实用案例就是删除DEDE文章中的链接且保留链接文字,用下边的SQL语句:
update dede_addonarticle set body = replace(body,substring(body,locate("<a ", body),locate(">", body,locate("<a ", body))+1-locate("<a ", body)),"");


All times are GMT +8. The time now is 10:38 PM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.