Jump to content

Replace one word with another in lots of rows in a database


oskare100

Recommended Posts

Hello,

Is there in any way (with MySQL or PHP or software) to replace one work with another in all rows in a table?

 

I have about 7000 product descriptions in Swedish and I need to translate them into English. The good thing is that all the description only contain a few words (I think that I just need to replace about 30 words in total to translate everything). The bad thing is that I don't know how to do that.

 

So I want to select all rows with the language id for English (currently all English decriptions are in Swedish) and then replace all occurances of a specific word with another specific word.

 

So UDPATE description ???? WHERE language_id = 5 is what I've figured wold be a start for an MySQL command... the problem is that I don't know what to put instead of ????.

 

Would it be possible to do that in PHP or MySQL? Could you help me with any kind of command (is that how you say it?) or any other help?

 

Regards /Oskar

Link to comment
Share on other sites

Might be worth looking at the syntax in question http://dev.mysql.com/doc/refman/5.0/en/update.html. In the place where you put ? ? ? you will want the column name(s) that you are replacing.

 

However I suspect that the real problem is that you have a long piece of text, inside which you need to replace 1 word, that sounds more like a regular expression issue. In which case you want something like this:

 

UPDATE <table name> SET description = REPLACE(description, 'word', 'replacement') WHERE language_id = 5;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.