MySQL Update Query从所有“description”字段中删除特定的Html标记

时间:2022-05-20 21:45:45

I have a Magento site in which each product has an anchor tag like <a href="link">Content</a> in their descrption field.

我有一个Magento网站,其中每个产品的描述字段中都有内容等锚标记。

Now I want to remove this anchor tag along with it's content inside the tag, but keep the rest of description as it is.

现在我想删除此锚标记及其在标记内的内容,但保留其余的描述。

Right now a sample description is like below:

现在,样本描述如下:

<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>

Now I want it show up like below:

现在我希望它显示如下:

<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>

How can I do this with an Update query ?

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

1 个解决方案

#1


0  

This will does the job ..!

这将完成工作..!

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

#1


0  

This will does the job ..!

这将完成工作..!

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