patternMinor
MySQL UPDATE to replace text in LONGTEXT field
Viewed 0 times
longtextfieldupdatetextreplacemysql
Problem
I have a WordPress table
For example, let's say that one record in the field
I'd like that to become:
I've tried the following query
but I don't get any result.
Any idea how to fix it?
wp_posts and I'd like to run an UPDATE that will replace a url from my old domain to my new domain.For example, let's say that one record in the field
post_content has the following content:This is my old web site.
I'd like that to become:
This is my old web site.
I've tried the following query
UPDATE wp_posts AS w`
SET w.post_content = REPLACE(w.post_content, 'my-old-site.com', 'my-new-site.com');but I don't get any result.
Any idea how to fix it?
Solution
There is an error in your query near
Alias name "w" should instead be
Try this:
AS w`Alias name "w" should instead be
`w`Try this:
UPDATE wp_posts AS `w`
SET w.post_content = REPLACE(w.post_content, 'my-old-site.com', 'my-new-site.com');Code Snippets
UPDATE wp_posts AS `w`
SET w.post_content = REPLACE(w.post_content, 'my-old-site.com', 'my-new-site.com');Context
StackExchange Database Administrators Q#14897, answer score: 6
Revisions (0)
No revisions yet.