为什么更新查询在 phpmyadmin 中没有按预期工作?
Why update query is not working as expected in phpmyadmin?
我正在尝试使用 phpMyadmin 替换 wordpress 帖子内容中的一些句子
这是我的更新查询
UPDATE `wp_posts` SET `post_content` = REPLACE (`post_content`, 'Example Routes:', 'Routes:') WHERE `post_content` LIKE '%Example Routes:%';
但它说“0 行受影响”。
我有 运行 一个 select 具有相同条件的查询,以确保有结果,我有很多结果
这是 select 查询
SELECT * FROM `wp_posts` WHERE `post_content` LIKE '%Example Routes:%';
请注意,这两个查询条件与我正在更新的条件相同,我的条件是"LIKE '%Example Routes:%'",更新是"REPLACE (post_content
, 'Example Routes:', 'Routes:')"。
知道为什么更新给我 0 行受影响吗?
尝试删除 REPLACE
和左括号之间的 space:
UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`, 'Example Routes:', 'Routes:')
WHERE `post_content` LIKE '%Example Routes:%';
默认情况下,不允许在函数名称及其括号之间包含白色space:http://dev.mysql.com/doc/refman/5.7/en/functions.html
经过大量搜索和变通,我发现 select 查询给出了结果,因为 LIKE
运算符不区分大小写,但 Replace 是,所以我需要替换 [=替换函数中的 16=] 到 'Example routes:' 有点棘手。
我最终使用了这个对我有用的查询
UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`,'Example routes:','Routes:')
WHERE `post_content` LIKE '%Example Routes:%';
我正在尝试使用 phpMyadmin 替换 wordpress 帖子内容中的一些句子 这是我的更新查询
UPDATE `wp_posts` SET `post_content` = REPLACE (`post_content`, 'Example Routes:', 'Routes:') WHERE `post_content` LIKE '%Example Routes:%';
但它说“0 行受影响”。
我有 运行 一个 select 具有相同条件的查询,以确保有结果,我有很多结果 这是 select 查询
SELECT * FROM `wp_posts` WHERE `post_content` LIKE '%Example Routes:%';
请注意,这两个查询条件与我正在更新的条件相同,我的条件是"LIKE '%Example Routes:%'",更新是"REPLACE (post_content
, 'Example Routes:', 'Routes:')"。
知道为什么更新给我 0 行受影响吗?
尝试删除 REPLACE
和左括号之间的 space:
UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`, 'Example Routes:', 'Routes:')
WHERE `post_content` LIKE '%Example Routes:%';
默认情况下,不允许在函数名称及其括号之间包含白色space:http://dev.mysql.com/doc/refman/5.7/en/functions.html
经过大量搜索和变通,我发现 select 查询给出了结果,因为 LIKE
运算符不区分大小写,但 Replace 是,所以我需要替换 [=替换函数中的 16=] 到 'Example routes:' 有点棘手。
我最终使用了这个对我有用的查询
UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`,'Example routes:','Routes:')
WHERE `post_content` LIKE '%Example Routes:%';