我正在尝试使用phpMyadmin替换wordpress帖子内容中的一些句子 这是我的更新查询
UPDATE `wp_posts` SET `post_content` = REPLACE (`post_content`, 'Example Routes:', 'Routes:') WHERE `post_content` LIKE '%Example Routes:%';
但它说“0行受影响”。
我运行了一个具有相同条件的select查询,以确保有resutls并且我有很多resutls 这是选择查询
SELECT * FROM `wp_posts` WHERE `post_content` LIKE '%Example Routes:%';
请注意,两个查询条件都与我更新的条件相同“LIKE'%示例路由:%'”,更新为“REPLACE(post_content
,'示例路由:','路线:')”
知道为什么更新会给我0行影响吗?
答案 0 :(得分:1)
尝试删除SELECT a.Record_id, a.Reference_id,V.Name
FROM TableA AS a
inner join
(
SELECT Doc_id id, NameB Name,'B' Type from TableB
UNION ALL
SELECT Doc_id ID, NameC name,'C' Type From TableC
) AS V On V.ID=Reference_id AND Type=Param
和左括号之间的空格:
REPLACE
默认情况下,不允许在函数名称和括号之间包含空格:http://dev.mysql.com/doc/refman/5.7/en/functions.html
答案 1 :(得分:0)
After a lot of search and working around I figured it out, the select query give results because the LIKE
operator is not case sensitive but Replace is, so I needed to replace 'Example Routes:' to 'Example routes:' in the replace function which is a bit tricky.
I ended up using this query which works for me
UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`,'Example routes:','Routes:')
WHERE `post_content` LIKE '%Example Routes:%';