mysql - 更改 HTML 列 MySQL 中的图像子域字符串

标签 mysql

我正在尝试更改“www”。到“cdn”。对于 MySQL 数据库中的每个 img 元素。

这是 HTML 列,因此其中的 a 标签等其他元素有点棘手,但我只想更改 img 标签

我试过 LIKE '%test%' 但不确定如何在这种情况下使用 UPDATE

执行此操作的最佳方法是什么?

下面是一个例子:

 

[nivoslider id="1952"]

 

[one-third first]
<h2><a title="diet" href="http://www.test.com.au/diet">Diet and Nutrition</a></h2>
<a title="diet" href="http://www.test.com.au/diet"><img class="size-full wp-image-965 alignnone" title="diet-and-nutrition-information" alt="diet-and-nutrition-information" src="http://www.test.com.au/wp-content/uploads/2012/10/Optimized-diet-and-nutrition-information.jpg" width="310" height="220" /></a>
A dietitian provides assistance and education for every day meal and exercise plans and provides advice and modified diet plans to treat health and medical conditions. Our dietitian is here to educate you and your family about healthy ways of living to reduce or maintain a healthy weight, cholesterol levels and detoxify our bodies to live a longer, healthier, more active lifestyle. Combined with nutrition, our dietitian and nutritionist can assist with food intolerances, digestive system and eating disorders and sports nutrition. <a title="Diet and Nutrition" href="http://www.test.com.au/diet-and-nutrition/"><strong>Read more.</strong></a>[end-column]

[one-third]
<h2><a title="skincare" href="http://www.test.com.au/skincare">Skincare</a></h2>
<a href="http://www.test.com.au/skincare/"><img class="alignnone size-full wp-image-1793" title="skincare-information" alt="skincare" src="http://www.test.com.au/wp-content/uploads/2012/10/Optimized-skincare-information3.jpg" width="310" height="220" />
</a>Human skin is our body’s largest organ. It is a complex series of layers of cells and its function is to provide a natural barrier to many things. As with any other organ in the body, you should take care of your skin and keep it healthy. There are many basic skincare steps you can take throughout your life to keep your skin looking fresh and feeling good from cosmetics to natural procedures and techniques. Understanding, caring and treatment of skin conditions and diseases is an important part of skincare and your overall health. <strong><a title="Skincare" href="http://www.test.com.au/skincare/">Read more.</a></strong>[end-column]

[one-third last]
<h2><a title="speech-pathology" href="http://www.test.com.au/speech-pathology">Speech Pathology</a></h2>
<a title="speech-pathology" href="http://www.test.com.au/speech-pathology"><img class="size-full wp-image-967 alignnone" title="speech-pathology" alt="speech-pathology" src="http://www.test.com.au/wp-content/uploads/2012/10/Optimized-speech-pathology-information.jpg" width="310" height="220" /></a>
Speech and language pathology is concerned with issues surrounding human speech and language communication disorders. Assistance with producing words can be helpful to both children and adults who lack clear speaking skills. Conditions treated at ENT Wellbeing include cognitive-linguistic, oral motor, language, swallowing, stuttering, voice, and speech disorders. Our ENT Wellbeing speech pathologist will perform a comprehensive diagnosis so that an effective treatment plan can be customized for the patient. <strong><a title="Speech Pathology" href="http://www.test.com.au/speech-pathology/">Read more.</a></strong> [end-column]

[schemaLocalBusiness]

我在下面尝试过但它不起作用:

UPDATE posts SET post_content = replace(post_content, 'src=\"http\:\/\/www\"', 'src=\"http\:\/\/cdn\"');

最佳答案

update table set column = replace(column, 'www.', 'cdn.')

关于mysql - 更改 HTML 列 MySQL 中的图像子域字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14008158/

相关文章:

python - 如何解决这种双重编码?

mysql - 通过连接限制每个组的 SQL 行数

PHP、cookie 和快速浏览器刷新

mysql - 使用MySQL对多个条件进行计数操作

php - 迁移后更新 Wordpress 密码导致登录错误

mysql - 在 MySQL 中创建第二个 PK 作为 AI

mysql开关大小写

MYSQL删除所有count(*)=1的结果

php - Laravel 的数据透视表问题

php - 为什么字符串格式的日期在 Phalcon 中无法正确比较?