php - 为什么更新查询在 phpmyadmin 中没有按预期工作?

标签 php mysql wordpress phpmyadmin

我正在尝试使用 phpMyadmin 替换 wordpress 帖子内容中的一些句子 这是我的更新查询

UPDATE `wp_posts` SET `post_content` = REPLACE (`post_content`,  'Example Routes:',  'Routes:') WHERE `post_content` LIKE '%Example Routes:%';

但它说“0 行受影响”。

我已经运行了一个具有相同条件的选择查询以确保有结果而且我有很多结果 这是选择查询

SELECT * FROM `wp_posts` WHERE `post_content` LIKE '%Example Routes:%';

请注意,这两个查询条件与我正在更新的条件相同,我的条件是“LIKE '%Example Routes:%'”,更新是“REPLACE (post_content, 'Example Routes: ', '路线:')"。

知道为什么更新给我 0 行受影响吗?

最佳答案

尝试删除 REPLACE 和左括号之间的空格:

UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`,  'Example Routes:',  'Routes:') 
WHERE `post_content` LIKE '%Example Routes:%';

默认情况下,不允许在函数名称及其括号之间包含空格:http://dev.mysql.com/doc/refman/5.7/en/functions.html

关于php - 为什么更新查询在 phpmyadmin 中没有按预期工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38310532/

相关文章:

php - img src 显示数据库中的错误用户

php - 在 PHP 中使用 PDO 绑定(bind)参数

php - 我正在使用数据库中的两个表并使用 PHP 在页面上显示

css - 无法使用 CSS(Wordpress 主题)删除上边距

css - 如何从 Wordpress 删除二十十四主题中的缩略图

php - 如果使用三元运算符,如何修复我的 PHP 内联?

mysql | mysql | PK 重复条目 - 非 PK 值更改已修复问题 - 为什么?

php - 使用 php 在 MySql 数据库中插入 Blob

wordpress - gatsby-source-graphql + ACF 字段未显示

php - html div 中的 href = php 变量