我想在 WordPress 帖子表中进行搜索和替换,但以帖子类型为条件 这就是我所得到的,并且 SELECTing 有效,但我不确定是否将“旧标题”替换为“新前缀旧标题”
UPDATE `wp_posts`
WHERE `post_title` REGEXP '^old title'
AND `post_type` = 'download'
set 'post_title' = replace( 'post_title', 'old title', 'new prefix old title');
最佳答案
set
子句应该在 where
子句之前。此外,post_title
是一个列名,而不是字符串文字,因此您不应使用单引号 ('
):
UPDATE `wp_posts`
SET `post_title` = REPLACE(`post_title`, 'old title', 'new prefix old title')
WHERE `post_title` REGEXP '^old title' AND `post_type` = 'download'
关于mysql - SQL(通过 phpMyAdmin),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46980604/