【发布时间】:2011-10-17 10:26:42
【问题描述】:
我想在我的一个 MySQL 数据库字段中查找并替换(或更准确地说,追加)一些 HTML,其中该字段包含特定的文本字符串。
我可以使用这个查询成功找到相关记录:
SELECT *
FROM `wp_posts`
WHERE `post_content` LIKE '%some phrase%'
此查询返回我想要附加 HTML 的所有记录。
所以我尝试使用以下查询来附加我想要使用的 HTML:
SELECT *
FROM `wp_posts`
WHERE `post_content` LIKE '%some phrase%'
UPDATE wp_posts SET post_content = REPLACE(post_content, '</strong></a>', '</strong></a>
<strong>Some additional piece of text</strong></p>')
但是返回错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE wp_posts SET post_content = INSERT(post_content, '</strong></a>', '</stro' at line 4
我认为它不喜欢我的 HTML 格式,但它应该如何格式化?
【问题讨论】:
标签: mysql html wordpress phpmyadmin mysql-error-1054