Forums / All Other Contributions/Addons / SQL query for site-wide word replacement?

SQL query for site-wide word replacement?

Started by bi11i on 22 May 2012, 4:25 PM · Views: 1,124

Results 1 to 8 of 8
22 May 2012, 4:25 PM
#1
bi11i avatar

bi11i

Zen Follower

Join Date:
Jun 2005
Location:
Portland, OR
Posts:
157
Plugin Contributions:
0

SQL query for site-wide word replacement?

I've managed to improperly capitalize a word on my site on multiple products and descriptions, as well.

Is there an easy via SQL to search for the word "Foo" and make it "foo", site-wide?

22 May 2012, 4:41 PM
#2
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,189
Plugin Contributions:
0

Re: SQL query for site-wide word replacement?

Sure there is ...
Just make sure you back up your data base first incase you mess up ..:smile:

http://www.zen-cart.com/showthread.php?124425-SQL-command-to-find-and-replace-a-word-in-the-products-description

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

22 May 2012, 4:59 PM
#3
bi11i avatar

bi11i

Zen Follower

Join Date:
Jun 2005
Location:
Portland, OR
Posts:
157
Plugin Contributions:
0

Re: SQL query for site-wide word replacement?

thanksl, although my word is also in the title of the product, will this replace that as well? If so, i'm assuming this is adequate?

UPDATE products_description SET products_description = REPLACE(products_description, "Foo'", "foo");
22 May 2012, 5:46 PM
#4
bi11i avatar

bi11i

Zen Follower

Join Date:
Jun 2005
Location:
Portland, OR
Posts:
157
Plugin Contributions:
0

Re: SQL query for site-wide word replacement?

bi11i:

thanksl, although my word is also in the title of the product, will this replace that as well? If so, i'm assuming this is adequate?

UPDATE products_description SET products_description = REPLACE(products_description, "Foo'", "foo");

22 May 2012, 5:58 PM
#5
bi11i avatar

bi11i

Zen Follower

Join Date:
Jun 2005
Location:
Portland, OR
Posts:
157
Plugin Contributions:
0

Re: SQL query for site-wide word replacement?

I see the mistake that I made here, got a little confused about the extra apostrophe in the example "2x3'". That worked great, except for product names - is there any easy to fix this, as well?

22 May 2012, 11:16 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: SQL query for site-wide word replacement?

You should be able to do essentially the same thing using the product name field. You will have to look up the correct table and field name(s). Note that there might be multiple tables to alter... not certain whether the product name is repeated, or purely linked by reference to the product id.

Look carefully at all "products_" tables and their fields.

22 May 2012, 11:47 PM
#7
bi11i avatar

bi11i

Zen Follower

Join Date:
Jun 2005
Location:
Portland, OR
Posts:
157
Plugin Contributions:
0

Re: SQL query for site-wide word replacement?

gjh42:

You should be able to do essentially the same thing using the product name field. You will have to look up the correct table and field name(s). Note that there might be multiple tables to alter... not certain whether the product name is repeated, or purely linked by reference to the product id.

Look carefully at all "products_" tables and their fields.afraid i'm not knowledgeable enough to be doing this kind of thing. I may resort to manually making the edits but the description suggestion was quite helpful and will save me some time.

thanks so much!

23 May 2012, 10:03 AM
#8
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: SQL query for site-wide word replacement?

If you really don't like playing around with phpmyadmin or sql commands, you could simply download your complete database as a file, put it into notepad, and simply do a word replace as you would with any text document, save the file and then re-upload your database.

Make a back up first though.