I am new to mysql and phpmyadmin so excuse my question if it’s basic.
I need a query to replace the 15$ to 10$ on all posts and pages post_title, post_excerpt and post_content using the insert method not update method.
also is there any way to undo the query if things went wrong ?
Question posted in PhpMyAdmin
The official documentation can be found here.
The official documentation can be found here.
4
Answers
You should back up your database first from
PHPMyAdmin
->Export
.You can’t
REPLACE
without UPDATE.As a second solution, after backup, if your MySQL dump is small enough, you could edit the SQL file with Notepad++, replace 15$ with 10$ and import everything in a new database and switch DB connections. This would meet the requirement: of using only the
INSERT
method.I’m not sure what your database looks like without an example and I’m not sure why you want to avoid the update method but maybe
this will help you with your question.
This does use the update function however but I don’t see a way around it other than exporting your database to an sql file, updating the rows through either a script or search and replace in a text editor.
My solution would be to use your text editor or use a query like
You might also want to take a look at this: How to search and replace all instances of a string within a database?
let me introduce my solution :
replace specific string in posts
UPDATE wp_posts SET post_title = REPLACE(post_title, ‘$15’, ‘$10’), post_content = REPLACE(post_content, ‘$15’, ‘$10’), post_excerpt = REPLACE(post_excerpt, ‘$15’, ‘$10’) WHERE post_type = ‘post’;
but I would recommend using the first answer for more covering
replace specific string in pages
change on wp yoast SEO plugin values meta_titles and meta_description