html - MySQL 更新查询以从所有 "description"字段中删除特定的 Html 标记

标签 html mysql sql regex magento

我有一个 Magento 网站,其中每个产品都有一个 anchor 标记,如 <a href="link">Content</a>在他们的描述字段中。

现在我想删除这个 anchor 标记及其在标记内的内容,但保持其余描述不变。

现在的示例描述如下:

<ul>
    <li>Cylinder head has been assembled to OEM specifications with using all new components like Cam shaft, valves and/or springs, buckets, shims etc. where applicable.</li>
    <li>
        <a href="http://sampledomain.com/media/wysiwyg/folder/file.pdf">All heads we supply pass through 24 points of quality check program.</a>
    </li>
    <li>Warranty: 1 year or 20,000 Kms factory warranty.</li>
    <li>
        <b>Kit Includes:</b>
    </li>
    <li>Fully assembled cylinder head</li>
    <li>VRS (Vehicle regrind set)</li>
    <li>Head gaskets (thickest grade)</li>
    <li>Head bolts</li>
    <li>Warranty card</li>
</ul>

现在我希望它显示如下:

<ul>
    <li>Cylinder head has been assembled to OEM specifications with using all new components like Cam shaft, valves and/or springs, buckets, shims etc. where applicable.</li>
    <li>
    </li>
    <li>Warranty: 1 year or 20,000 Kms factory warranty.</li>
    <li>
        <b>Kit Includes:</b>
    </li>
    <li>Fully assembled cylinder head</li>
    <li>VRS (Vehicle regrind set)</li>
    <li>Head gaskets (thickest grade)</li>
    <li>Head bolts</li>
    <li>Warranty card</li>
</ul>

如何使用更新查询执行此操作?

最佳答案

这将完成工作..!

UPDATE your_table_name  
set description = 
concat
(
substring_index(description, '<a',1), 
substring_index(description, '</a>',-1)
);

关于html - MySQL 更新查询以从所有 "description"字段中删除特定的 Html 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37405819/

相关文章:

MySQL SUM 具有相同 ID 的单元格并将其插入表中

html - Flexbox - 显示页眉和页脚

javascript - 在模态中自动单击按钮

mysql - 无法访问远程mysql服务器需要帮助

mysql - 带有 MySQL UNION 的经典 ASP

php数据库表选择受限

PHP 使用 DOMDocument 从 URL 中检索内部 HTML 作为字符串

android - Android、iPhone 和 Web 上的多人游戏

mysql - 选择具有特定组合的行

mysql - 搜索条目 - 在数据库中(不指定列名称/表名称)