Domanda

I am a litle rusty with DB managment and I have to do some operations on a DB. I have some doubts about what exactly the following MySql query does:

UPDATE wp_posts SET post_content = REPLACE(post_content,'www.domain.com/wp-content/uploads','www.domain.com/images');

I think that it update thes content of the post_content column of the wp_post table (is it right?).

But I am not sure about what the REPLACE function does, and ultimately what is the exact behavior of the whole query?

Can anybody help me with this?

È stato utile?

Soluzione

It's updating the value of post_content in all rows in the table.

If the post_content column contains the text www.domain.com/wp-content/uploads, then it is replaced with www.domain.com/images.

If post_content doesn't contain that text, then no action is taken on that row.

If, for example, it contains:

http://www.domain.com/wp-content/uploads/blah/blah/blah.jpg

then it will become:

http://www.domain.com/images/blah/blah/blah.jpg

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top